Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- secret = random.randint(1,20)
- guess = 0
- tries = 0
- print('Try to guess a number between 1 and 20, You have 5 guesses')
- while (guess != secret) and (tries < 5):
- guess = int(input ("What is your guess? "))
- tries = tries + 1
- if guess == secret:
- print('You got it')
- elif tries == 1 and guess < secret:
- print('Your first clue is that your guess is too low, try again')
- elif tries == 1 and guess > secret:
- print('Your first clue is that your guess is too high, try again')
- elif tries == 2 and (secret/2)<7:
- print('No, sorry, your second clue is that the secret number divided by 2 is less than 7')
- elif tries == 2 and (secret/2)>=7:
- print('No, sorry, your second clue is that the secret number divided by 2 is >= 7')
- elif tries == 3:
- print('Still not right. Your third clue is that the floor division of the number / 3 = '+ str(secret//3 ))
- elif tries == 4:
- print('No, the final clue is that the modulus of the number / 4 = '+ str(secret%4))
- if guess!=secret:
- print ('Wrong, sorry, you have used up your five guesses. Better luck next time.')
- print ('The secret number was ' + str(secret))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement