时间:2021-05-22
近日在学习Python的一些基础知识,觉得还是很有趣的一个一门语言!就目前的学习的一些知识,编写了一些一个简单的石头剪刀布的游戏。主要是熟悉一些Python的一些控制语句。
import randomwhile 1: s=int(random.randint(1,3)) print(s) print() if s==1: ind="stone" elif s==2: ind="scissors" elif s==3: ind="paper" m=input('Please input your option,if you input the end, this game will be end. ') blist=['stone','scissors','paper'] if (m not in blist) and (m!='end'): print('your input is wrong and please input the right option again or end the game: ') elif (m not in blist) and (m=='end'): print('the game is ending now...') break elif m==ind: print('draw') elif (m=='stone' and ind=='scissors') or (m=='paper' and ind=='stone') or (m=='scissors' and ind=='paper'): print('you win this game') elif (m=='stone' and ind=='paper') or (m=='paper' and ind=='scissors') or (m=='scissors' and ind=='stone'): print( 'you loss this game')下面是结果:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
ruby实现石头剪刀布游戏复制代码代码如下:#encoding:utf-8arr=['石头','剪刀','布']win_arr=[['石头','剪刀'],['剪
本文实例为大家分享了C#语言使用Unity实现剪刀石头布游戏的具体代码,供大家参考,具体内容如下游戏:剪刀石头布实现功能:1、电脑随机出牌(剪刀石头布)2、玩家
本文实例讲述了php实现的网页版剪刀石头布游戏。分享给大家供大家参考,具体如下:剪刀石头布剪刀石头布,你出什么?剪刀石头布运行效果图如下:更多关于PHP相关内容
Python石头剪刀布小游戏(三局两胜),供大家参考,具体内容如下importrandomall_choioces=['石头','剪刀','布']win_lis
今天的这篇文章呢是对人机猜拳小游戏——石头剪刀布的一个描述以及代码展现石头剪刀布游戏代码的简介:关于石头剪刀布这个小游戏,大致得到思路就是,玩家出一个手势,然后