Advertisement
johnpentyrch

math29

Feb 20th, 2022
922
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.61 KB | None | 0 0
  1. import random
  2. secret = random.randint(1,20)
  3. print('secret ',secret) ##debug line
  4. guess = 0
  5. tries = 0
  6. print('Try to guess a number between 1 and 20, using the four clues if you need them.')
  7. print('You have 5 guesses.')
  8. while (guess != secret) and (tries < 5):
  9.     guess = int(input('What is your guess? '))
  10.     tries = tries + 1
  11.     if guess == secret:
  12.         print('You got it')
  13.     elif tries == 1 and guess < secret:
  14.         print('Your first clue is that your guess is too low, try again')
  15.     elif tries == 1 and guess > secret:
  16.         print('Your first clue is that your guess is too high, try again')
  17.     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)):
  18.         print('Your second clue is that the secret number is prime, try again')
  19.     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)):
  20.         print('Your second clue is that the secret number is not prime, try again')
  21.     elif tries == 3:
  22.         print('Your third clue is that secret number divided by 3 has a remainer, ',(secret%3) ,' try again')
  23.     elif tries == 4 and ((secret % 2) == 1 ):
  24.         print('Your final clue is that the secret number is odd, try again')
  25.     elif tries == 4 and ((secret % 2) == 0 ):
  26.         print('Your second clue is that the secret number is even, try again')
  27.    
  28.  
  29.  
  30. if guess != secret:    
  31.     print ('Wrong, sorry, you have used up your five guesses. Better luck next time.')
  32.     print ('The secret number was', secret)
  33.  
  34.  
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement