Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import time
- import easygui
- import sys
- while True:
- rand = random.choice(["Heads", "Tails"])
- firstguess = easygui.buttonbox("Pick one", choices= ["Heads", "Tails"])
- if firstguess == rand:
- easygui.msgbox("Wow you win!")
- else:
- easygui.msgbox("Sorry you guessed wrong!")
- time.sleep(2)
- answer = easygui.buttonbox("Play again?", choices=["Yes","No"])
- if answer == "Yes":
- pass
- else:
- break
- easygui.msgbox("Ok, see you later!")
- sys.exit(0)
- if answer == "Yes":
- pass
- else:
- break
- if answer != "Yes":
- break
- answer = easygui.buttonbox("Play again?", choices=["Yes","No"])
- if answer != "Yes":
- break
- play_again = easygui.ynbox("Play again?")
- if not play_again:
- break
- if not easygui.ynbox("Play again?"):
- break
- import random # alphabetic order
- import time
- import easygui # third-party modules after standard-library modules
- CHOICES = ["Heads", "Tails"] # ALL_CAPS for variables whose value never changes
- while True:
- result = random.choice(CHOICES)
- guess = easygui.buttonbox("Pick one", choices=CHOICES)
- if guess == result:
- easygui.msgbox("Wow you win!")
- else:
- easygui.msgbox("Sorry you guessed wrong!")
- time.sleep(2)
- if not easygui.ynbox("Play again?"):
- break
- easygui.msgbox("Ok, see you later!")
- """This docstring explains the program's purpose.
- Here's some more details, including descriptions of any command-line arguments.
- """
- # Keep imports in sorted order
- import bar
- import foo
- import sys
- # Define helper functions, classes, etc
- def baz(...):
- """Functions and classes get docstrings too."""
- ...
- def main(argv):
- ...
- if __name__ == '__main__':
- main(sys.argv) # This passes commandline arguments to your main function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement