Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. CurSequence = 1
  2. NegSequence = 0
  3. GreatSequence = 0
  4. while (1==1):
  5.     IntInput = input("Enter a positive integer or quit with 'q': ")
  6.     if str(IntInput) == "q":
  7.         break
  8.     if int(IntInput) < 0:
  9.         print("You entered a negative integer.")
  10.     else:
  11.         LastInt = IntInput
  12.         GreatSequence = CurSequence
  13.         break
  14.  
  15. while (1==1):
  16.     if str(IntInput) == "q":
  17.         break
  18.     IntInput = input("Enter a positive integer or quit with 'q': ")
  19.     if IntInput == "q":
  20.         break
  21.     if NegSequence == 3:
  22.         break
  23.     if int(IntInput) < 0:
  24.         print("You entered a negative integer.")
  25.         continue
  26.     else:
  27.         if int(IntInput) > int(LastInt):
  28.             CurSequence = CurSequence + 1
  29.             NegSequence = 0
  30.             LastInt = IntInput
  31.             if CurSequence > GreatSequence:
  32.                 GreatSequence = CurSequence
  33.         elif int(IntInput) < int(LastInt):
  34.             NegSequence = NegSequence + 1
  35.             CurSequence = 0
  36.             LastInt = IntInput
  37.         else:
  38.             print("You entered the same number!")
  39. print("The greatest sequence of numbers was " + str(GreatSequence))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement