Guest User

Untitled

a guest
Sep 10th, 2025
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import random
  2.  
  3. print("Let's play a number guessing game")
  4. print("I'll select a number and you'll guess it")
  5. print("Hint: it is between 1 and 100 XD")
  6. print("Let us start :)")
  7.  
  8. number = random.randint(1, 100)
  9.  
  10. while True:
  11. try:
  12. guess = int(input("What is your guess? "))
  13. except ValueError:
  14. print("Sorry, only numbers. Let's try again.")
  15. continue
  16.  
  17. difference = abs(number - guess)
  18. if difference == 0:
  19. print("Yay! You've guessed it correctly!!")
  20. break
  21.  
  22. if difference <= 4:
  23. guess = print("Very close! Let's try again.")
  24. elif difference <= 9:
  25. guess = print("Hot! Let's try again.")
  26. else:
  27. guess = print("Cold! Let's try again.")
Advertisement
Add Comment
Please, Sign In to add comment