当前位置:   article > 正文

python 人机对战_python人马大战csdn免费专区

python人马大战csdn免费专区

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
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/340280
推荐阅读
相关标签
  

闽ICP备14008679号