Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Operator game adding hints
- import random
- secret = random.randint(1,20) # Return a random integer N such that a <= N <= b. Alias for randrange(a, b+1).
- guess = 0
- tries = 0
- print('Try to guess a number between 1 and 20, using the four clues if you need them.')
- print('You have 5 guesses.')
- while (guess != secret) and (tries < 5): # Attempts 0, 1, 2, 3, 4 and in total are 5
- guess = int(input('What is your guess? '))
- tries = tries + 1
- if tries == 1 and guess < secret:
- print('Your first clue is that your guess is too low, try again') # For first intent and guess < secret
- elif tries == 1 and guess > secret:
- print('Your first clue is that your guess is too high, try again') # For first intent and guess > secret
- elif tries == 2 and (secret%10==0):
- print('Your second clue is that your guess is divisible by ten, try again') # For second intent and secret divisible by 10
- elif tries == 2:
- print('Your second clue is that your guess is not divisible by ten, try again') # For second intent and secret no divisible by 10
- elif tries == 3 and (secret%5==0):
- print('Your third clue is that your guess is divisible by five, try again') # For third intent and secret divisible by 5
- elif tries == 3:
- print('Your third clue is that your guess is not divisible by five, try again') # For third intent and secret no divisible by 5
- elif tries == 4 and (secret%2==0):
- print('Your fourth clue is that your guess is divisible by 2, try again') # For fourth intent and secret divisible by 2 (even)
- elif tries == 4:
- 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)
- else:
- print('This is the last opportunity') # For fifth and last intent
- if guess == secret:
- print('You got it')
- else:
- print ('Wrong, sorry, you have used up your five guesses. Better luck next time.')
- print ('The secret number was', secret)
Add Comment
Please, Sign In to add comment