Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. import random
  2. import time
  3. import easygui
  4. import sys
  5. while True:
  6. rand = random.choice(["Heads", "Tails"])
  7. firstguess = easygui.buttonbox("Pick one", choices= ["Heads", "Tails"])
  8. if firstguess == rand:
  9. easygui.msgbox("Wow you win!")
  10. else:
  11. easygui.msgbox("Sorry you guessed wrong!")
  12. time.sleep(2)
  13. answer = easygui.buttonbox("Play again?", choices=["Yes","No"])
  14. if answer == "Yes":
  15. pass
  16. else:
  17. break
  18.  
  19. easygui.msgbox("Ok, see you later!")
  20. sys.exit(0)
  21.  
  22. if answer == "Yes":
  23. pass
  24. else:
  25. break
  26.  
  27. if answer != "Yes":
  28. break
  29.  
  30. answer = easygui.buttonbox("Play again?", choices=["Yes","No"])
  31. if answer != "Yes":
  32. break
  33.  
  34. play_again = easygui.ynbox("Play again?")
  35. if not play_again:
  36. break
  37.  
  38. if not easygui.ynbox("Play again?"):
  39. break
  40.  
  41. import random # alphabetic order
  42. import time
  43.  
  44. import easygui # third-party modules after standard-library modules
  45.  
  46. CHOICES = ["Heads", "Tails"] # ALL_CAPS for variables whose value never changes
  47.  
  48. while True:
  49. result = random.choice(CHOICES)
  50. guess = easygui.buttonbox("Pick one", choices=CHOICES)
  51. if guess == result:
  52. easygui.msgbox("Wow you win!")
  53. else:
  54. easygui.msgbox("Sorry you guessed wrong!")
  55. time.sleep(2)
  56. if not easygui.ynbox("Play again?"):
  57. break
  58.  
  59. easygui.msgbox("Ok, see you later!")
  60.  
  61. """This docstring explains the program's purpose.
  62.  
  63. Here's some more details, including descriptions of any command-line arguments.
  64. """
  65.  
  66. # Keep imports in sorted order
  67. import bar
  68. import foo
  69. import sys
  70.  
  71. # Define helper functions, classes, etc
  72. def baz(...):
  73. """Functions and classes get docstrings too."""
  74. ...
  75.  
  76. def main(argv):
  77. ...
  78.  
  79. if __name__ == '__main__':
  80. main(sys.argv) # This passes commandline arguments to your main function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement