Advertisement
Tom_Jung

Untitled

Apr 24th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. # Future Learn / Logic & Maths / Guessing Game
  2.  
  3. import random
  4. secret = random.randint(1,50)
  5. #print("Secret number is ", secret)
  6.  
  7. guess = 0
  8. tries = 0
  9.  
  10. print("Guess a number between 1 and 50 in five tries.")
  11.  
  12. while (guess!=secret) and (tries<5):
  13.  
  14. guess = int(input("Enter your guess: "))
  15.  
  16. tries = tries + 1
  17. print("Tries = ", tries)
  18.  
  19. if guess == secret:
  20. print("Yeah, you got it!")
  21. elif guess < secret:
  22. print("Your guess it too low")
  23. elif guess > secret:
  24. print("your guess is too high")
  25.  
  26. if tries==5 and guess!=secret:
  27. print("You are out of tries")
  28. print("You did not guess the secret number")
  29. print("The secret number is ", secret)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement