crzcas

operator game with hints

Dec 28th, 2020 (edited)
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.07 KB | None | 0 0
  1. # Operator game adding hints
  2.  
  3. import random
  4. secret = random.randint(1,20)  # Return a random integer N such that a <= N <= b. Alias for randrange(a, b+1).
  5. guess = 0
  6. tries = 0
  7.  
  8. print('Try to guess a number between 1 and 20, using the four clues if you need them.')
  9. print('You have 5 guesses.')
  10.  
  11. while (guess != secret) and (tries < 5):   # Attempts 0, 1, 2, 3, 4 and in total are 5
  12.     guess = int(input('What is your guess? '))
  13.     tries = tries + 1
  14.  
  15.     if tries == 1 and guess < secret:
  16.         print('Your first clue is that your guess is too low, try again')   # For first intent and guess < secret
  17.     elif tries == 1 and guess > secret:
  18.         print('Your first clue is that your guess is too high, try again')   # For first intent and guess > secret
  19.        
  20.     elif tries == 2 and (secret%10==0):
  21.         print('Your second clue is that your guess is divisible by ten, try again')   # For second intent and secret divisible by 10
  22.     elif tries == 2:
  23.         print('Your second clue is that your guess is not divisible by ten, try again')  # For second intent and secret no divisible by 10
  24.        
  25.     elif tries == 3 and (secret%5==0):
  26.         print('Your third clue is that your guess is divisible by five, try again')   # For third intent and secret divisible by 5
  27.     elif tries == 3:
  28.         print('Your third clue is that your guess is not divisible by five, try again')   # For third intent and secret no divisible by 5    
  29.      
  30.     elif tries == 4 and (secret%2==0):
  31.         print('Your fourth clue is that your guess is divisible by 2, try again')   # For fourth intent and secret divisible by 2 (even)
  32.     elif tries == 4:
  33.         print('Your fourth clue is that your guess is not divisible by 2, try again')  # For fourth intent and secret no divisible by 2 (odd)
  34.        
  35.     else:
  36.         print('This is the last opportunity')   # For fifth and last intent
  37.      
  38.  
  39. if guess == secret:
  40.     print('You got it')
  41.    
  42. else:
  43.     print ('Wrong, sorry, you have used up your five guesses. Better luck next time.')
  44.     print ('The secret number was', secret)
Add Comment
Please, Sign In to add comment