if语句嵌套
# draw up at a station
print("Welcome to ChengDu railway station!")
is_ticket = input("Have a ticket? True or False:")
if is_ticket:
print("Welcome,please go to security check!")
else:
print("please buy a ticket")
if is_ticket:
controlled_knife = input("the length of knife:")
if controlled_knife >= 20:
print("prohibit enter the station")
else:
print("Welcome to ride!")
# the game of Rock Paper Scissors
import random
player = input("Please show your fist:Rock(1),Paper(2),Scissorrs(3)")
computer = random.randint(1,3)
print("the fist of player is %d VS the fist of computer is %d"%(player,computer))
if ((player == 1 and computer == 3)
or (player == 2 and computer == 1)
or (player == 3 and computer == 2)):
print("Yeah,player win!")
elif player == computer:
print("We are eye to eye.")
else:
print("Oh,no.Game over!")
近期评论