Python实现石头-剪刀-布小游戏
2017-08-09 10:35
411 查看
近日在学习Python的一些基础知识,觉得还是很有趣的一个一门语言!就目前的学习的一些知识,编写了一些一个简单的石头剪刀布的游戏。主要是熟悉一些Python的一些控制语句。
下面是结果:
看着应该还可以,比较简单,我会继续学些!
import random while 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')
下面是结果:
看着应该还可以,比较简单,我会继续学些!
相关文章推荐
- 以写代学:python实现 剪刀、石头、布游戏
- 用Python实现的"石头,剪刀,布"
- python脚本小游戏,剪刀石头布.
- java实现剪刀石头布功能
- JSP剪刀石头布的设计与实现
- 命名管道实现进程间通信--石头、剪刀、布游戏 分类: linux 2014-06-01 22:50 467人阅读 评论(0) 收藏
- 命名管道实现进程间通信--石头、剪刀、布游戏
- python 剪刀石头布的入门demo
- java基础总结 --- enum枚举实现多路分发 石头、剪刀、布游戏示例
- Python 剪刀石头布 小游戏
- 简单小游戏-剪刀石头布的c语言实现
- python核心编程第六章题目:python代码实现:设计一个"石头,剪子,布"游戏
- 用Python写剪刀石头布小游戏-解法2
- (Rock, Paper, Scissors, Lizard and Spock)sheldon谢耳朵独创的剪刀,布,石头,蜥蜴,史波克 用代码实现
- 剪刀石头布小习题三种语言python2、php、go代码
- Python 剪刀石头布
- Unity-->实现剪刀石头布的游戏
- 用C#语言在Unity中实现剪刀石头布的游戏
- 从键盘接收字符类型的数据并实现剪刀石头布的规则
- 机器学习算法与Python实践之(四)支持向量机(SVM)实现