python学习笔记04(点球游戏)

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))

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值