Last active
November 8, 2018 02:43
-
-
Save JoseALermaIII/b86116a6364525422bc3bb5d2e3b1ae9 to your computer and use it in GitHub Desktop.
Nifty cover photo that plays a game of heads or tails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! python3 | |
# -*- coding: utf-8 -*- | |
"""Plays a game of heads or tails. | |
Nifty cover photo that plays a game of heads or tails. | |
Attributes: | |
witty_message (str): A greeting to display upon startup. | |
name (str): User's inputted name. | |
playing_videogames (str): User's inputted response for whether they want to play. | |
answer (str): Automatically selected choice between 'heads' or 'tails'. | |
guess (str): User's inputted guess between 'heads' or 'tails'. | |
""" | |
from random import choice | |
witty_message = 'Yo.' | |
print(witty_message) | |
name = str(input('Say, what\'s your name? ')) | |
print(f'G\'day, {name}!') | |
while True: | |
playing_videogames = str(input('Shall we play a game? Y/N ')) | |
if playing_videogames.lower().startswith('n'): | |
break | |
answer = choice(['heads', 'tails']) | |
guess = str(input(f'Okay, {name}: heads or tails? ')) | |
if guess != answer: | |
print(f'Bummer {name}, you got it wrong...') | |
else: | |
print(f'Congrats {name}, you got it right!') | |
print(f'Until we play again, {name}, farewell!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is code that I made up to use as a background in a custom cover photo I made.
I made this gist to show that the code is complete and works.