import random
choice = input ("please,choice 1:Heads,tails\n").lower()
print ("Choose a method to toss coin: ( 1 or 2 )")
print ("1. Using random.randint()")
print ("2. Using random.random()")
met=input ("")
if met == '1':
ran=random.randint(0,1)
if ran ==0:
print ("it is tails")
O= ("tails").lower ()
if choice== O :
print ("you win")
else :
print ("sorry, you lost")
else :
print ("it is Heads")
L = ("Heads").lower()
if choice== L :
print ("you win")
else :
print ("sorry, you lost")
elif met == '2':
rans=random.random()
if rans >=0.5:
print ("it is tails")
O= ("tails").lower ()
if choice== O :
print ("you win")
else :
print ("sorry, you lost")
else :
print ("it is Heads")
L = ("Heads").lower()
if choice== L :
print ("you win")
else :
print ("sorry, you lost")
else:
print ("sorry, I can't understand you.")
5 إعجابات
احسنت اخي بارك الله فيك
إعجابَين (2)