python 人机对战

python 人机对战

来来来~~~我这有一个你和你的电脑比赛的项目
有没有胆量和你的电脑一决高下呢?
二话不说
代码供上:

#conding:uft-8
#人机对战
import easygui,time #导库
num = 0 #定义游玩次数
class Wen(): #创建问答类
    def wen(self, computer_score=0,player_score = 0):#定疑问函数(方法),定义局部变量
    # 以下代码仅供参考,内容可以自行修改
        a = easygui.enterbox('请输入你要的答题类型' + '\n' + 'A.诗词类' + '\n' + 'B.猜歌类' + '\n' + 'C.烧脑类')
        if a == 'A':
            easygui.msgbox('好的,请准备。三秒后开始')
            time.sleep(3)
            b = easygui.enterbox('下面哪那个是李白的诗' + '\n' + 'A.听取蛙声一片' + '\n' + 'B.孤帆远影碧空尽')
            if b =='A':
                easygui.msgbox('回答错误')
                computer_score = computer_score + 1
                easygui.msgbox('得分' + str(player_score) + ':' + str(computer_score))
                time.sleep(1)
            if b == 'B':
                easygui.msgbox('回答正确')
                player_score = player_score + 1
                easygui.msgbox('得分' + str(player_score) + ':' + str(computer_score))
                time.sleep(1)
            c = easygui.enterbox('一行白鹭上青天是谁写的' + '\n' + 'A.杜甫' + '\n' + 'B.李白')
            if c == 'A':
                easygui.msgbox('回答正确')
                player_score = player_score + 1
                easygui.msgbox('得分' + str(player_score) + ':' + str(computer_score))
                time.sleep(1)
            if c == 'B':
                easygui.msgbox('回答错误')
                computer_score = computer_score + 1
                easygui.msgbox
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值