赞
踩
来来来~~~我这有一个你和你的电脑比赛的项目
有没有胆量和你的电脑一决高下呢?
二话不说
代码供上:
#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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。