Untitled

mail@pastecode.io avatar
unknown
python
25 days ago
729 B
2
Indexable
Never

# Online Python - IDE, Editor, Compiler, Interpreter
#import random
import random

mycoin = -1; #coin starts with invalid value

#Get user's input
print("Guess a coin side by entering Heads or Tails.")
myguess = input()

mycoin = random.randint(0, 1); #flip coin

#display what the coin landed on
if (mycoin == 0) :  #if landed on heads
    if (myguess == "Heads") :   #check guess
        print("Correct, the coin landed on heads!")
    else :
        print("Incorrect, the coin landed on heads.")
elif (mycoin == 1) :    #if landed on tails
    if (myguess == "Tails") :
        print("Correct, the coin landed on tails!")
    else :
        print("Incorrect, the coin landed on tails")
else :
    print("Coin hasn't flipped")
Leave a Comment