Untitled
unknown
python
a year ago
1.0 kB
7
Indexable
# Online Python - IDE, Editor, Compiler, Interpreter
#import random
import random
mycoin = -1; #coin starts with invalid value
guesscheck = "null"
while (guesscheck == "null") :
#Get user's input
print("Guess a coin side by entering Heads or Tails.")
myguess = input()
if (myguess != "Heads") :
if (myguess != "Tails") :
print("Incorrect input")
myguess = "null"
else :
guesscheck = "good"
else :
guesscheck = "good"
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")Editor is loading...
Leave a Comment