from random import choice
sorce_com = 0
sorce_you = 0
direction = ["left","center","right"]
for i in range (5):
print("===Round %d - You kick!===" %(i+1))
print("Choose one side to shoot:")
print("left,center,right")
you = input() #输入射门方向
print("You kicked " + you)
com = choice(direction) #电脑随机扑救方向
print("Computer choose " + com)
if(you != com): #方向不同,进球
print("Goal!")
sorce_you += 1
else:
print("Oops")
print("Score: %d(you) - %d(com)\n" %(sorce_you, sorce_com))
print("===Round %d - You Save!===" %(i+1))
print("Choose one side you save:")
print("left,center,right")
you = input() #输入扑救方向
print("You saved " + you)
com = choice(direction) #电脑随机射门方向
print("Computerkicked " + com)
if(you == com): #方向相同,球被扑出
print("Saved")
else:
print("Oops")
sorce_com += 1 #电脑得分
print("Score: %d(you) - %d(com)\n" %(sorce_you, sorce_com))
python学习笔记04(点球游戏)
最新推荐文章于 2023-07-13 15:23:06 发布