Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- secret = random.randint(1,20)
- print('secret ',secret) ##debug line
- 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):
- 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) or (secret==3) or (secret==5) or (secret==7) or (secret ==11) or (secret==13) or (secret==17) or (secret==19)):
- print('Your second clue is that the secret number is prime, try again')
- elif tries == 2 and ((secret !=2) or (secret!=3) or (secret!=5) or (secret!=7) or (secret !=11) or (secret!=13) or (secret!=17) or (secret!=19)):
- print('Your second clue is that the secret number is not prime, try again')
- elif tries == 3:
- print('Your third clue is that secret number divided by 3 has a remainer, ',(secret%3) ,' try again')
- elif tries == 4 and ((secret % 2) == 1 ):
- print('Your final clue is that the secret number is odd, try again')
- elif tries == 4 and ((secret % 2) == 0 ):
- print('Your second clue is that the secret number is even, try again')
- if guess != secret:
- print ('Wrong, sorry, you have used up your five guesses. Better luck next time.')
- print ('The secret number was', secret)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement