Guest User

Untitled

a guest
Feb 2nd, 2023
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. !import random
  2. from art import logo
  3.  
  4. def is_guessed(n1, n2):
  5. if n1 == n2:
  6. print(f"You got it! The answer was {n1}!")
  7. return False
  8. elif n1 > n2:
  9. print("Too high")
  10. print("Guess again")
  11. return True
  12. else:
  13. print("Too low")
  14. print("Guess again")
  15. return True
  16.  
  17. print(logo)
  18. print("Welcome to the Number Guessing Game!")
  19. print("I'm thinking of a number between 1 and 100")
  20. decision = input("Choose a difficulty. Type 'easy' or 'hard': ")
  21. if decision == "easy":
  22. lives = 10
  23. number = random.randint(1,101)
  24. print(f"You have {lives} attempts remaining to guess the number.")
  25. guess = int(input("Make a guess: "))
  26. should_continue = is_guessed(guess, number)
  27. while should_continue:
  28. if lives > 1:
  29. lives -= 1
  30. print(f"You have {lives} attempts remaining to guess the number.")
  31. guess = int(input("Make a guess: "))
  32. should_continue = is_guessed(guess, number)
  33. else:
  34. print(f"You've run out of guesses, you lose")
  35. should_continue = False
  36. elif decision == "hard":
  37. lives = 5
  38. number = random.randint(1, 101)
  39. print(f"You have {lives} attempts remaining to guess the number.")
  40. guess = int(input("Make a guess: "))
  41. should_continue = is_guessed(guess, number)
  42. while should_continue:
  43. if lives > 1:
  44. lives -= 1
  45. print(f"You have {lives} attempts remaining to guess the number.")
  46. guess = int(input("Make a guess: "))
  47. should_continue = is_guessed(guess, number)
  48. else:
  49. print(f"You've run out of guesses, you lose")
  50. should_continue = False
  51.  
Advertisement
Add Comment
Please, Sign In to add comment