Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. import random
  2. money = 10
  3. count = 0
  4.  
  5. def counter():
  6. global money
  7. global count
  8. if g == r:
  9. if choice == 1:
  10. print "You guessed right! You win $2\n"
  11. money = money + 2
  12. count = count + 1
  13. if choice == 2:
  14. print "You guessed right! You win $5\n"
  15. money = money + 5
  16. count = count + 1
  17. else:
  18. print "Incorrect!"
  19. print "You have guessed:", count, "numbers right.\n"
  20.  
  21. #main
  22. message = raw_input("Hello! This is a guessing game. Here are the rules: \n\n1. You start out with $10 \n2. You can play the easy or hard mode each round. \n3. The easy mode is $1 to play and if you guess the number between 1-2 correctly you win $2. \n4. The hard mode is $2 to play and if you guess the number between 1-5 correctly you win $5.\n5. If you guess the number right 3 times, before you run out of money, you win! \n6. The game text will tell you what to do, just follow the instructions! \n\nPress enter to start!\n")
  23. while money > 0:
  24. print "You have $", money,
  25. choice = input("Which game mode would you like to play? \neasy for $1 - enter 1 \nhard for $2 - enter 2\n-->")
  26. if choice == 1:
  27. if money >= 1:
  28. money = money - 1
  29. r = random.randrange(2) + 1
  30. g = input("\nPick a number from 1 to 2:")
  31. counter()
  32. elif choice == 2:
  33. if money >= 2:
  34. money = money - 2
  35. r = random.randrange(5) + 1
  36. g = input("\nPick a number from 1 to 5:")
  37. counter()
  38. elif money == 1:
  39. print "You don't have enough money to play this version, try the easy version.\n"
  40. choice = 1
  41. if money == 0:
  42. print "You lost! You ran out of money. \nPress run to play again!"
  43. if count == 3:
  44. print "You guessed the number 3 times before you ran out of money! You won! \nPress run to play again!"
  45. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement