Python 剪刀石头布小游戏程序

 时间:2024-10-17 20:55:15

1、打开Python 软件,新建Python files

Python 剪刀石头布小游戏程序

2、输入代码如下:import random,timepunches = [争犸禀淫'石头','剪刀','布']computer_choi艘早祓胂ce = random.choice(punches)while True: user_choice='' user_choice=input('请出拳:(剪刀,石头,布)') while user_choice not in punches: print('输入错误,请重新出拳:') user_choice=input() print('----战斗过程----') print(computer_choice) print(user_choice) time.sleep(1) if (computer_choice=='石头' and user_choice=='布') or (computer_choice=='布' and user_choice=='剪刀') or (computer_choice=='剪刀' and user_choice=='石头'): print('yeah,你赢了!') break elif computer_choice==user_choice: continue else: print('Oh,你输了') break

Python 剪刀石头布小游戏程序

4、分别测试几种输出的不同 结果1.输入‘石头’,电脑出‘布’,结果是你输了2.输入‘one punch’,错误汜枸赓觅指令,提示重新输入,重新输入‘石头’,电脑出‘布’,结果是你赢了3.输入‘石头‘,电脑出’石头‘,打和了,但是打和是不存在的,还是要决一胜负的,提示重新出拳,重新输入’布‘,电脑出’石头‘,终于决出结果,你赢了!

Python 剪刀石头布小游戏程序Python 剪刀石头布小游戏程序
  • ps教程:制作绿色草坪效果图
  • 设计中运动空间与停滞空间
  • 浦城民间炸弹
  • 好听的赵姓女孩名字
  • 靠山的地方要怎么规划
  • 热门搜索
    华为荣耀9怎么样 雅漾防晒霜怎么样 tga文件怎么打开 如何组建团队 微信企业号怎么注销 如何制作个人简历 新疆旅游报价 黄山学院怎么样 psp金手指怎么用 如何学好地理