#Python 初学之二编写一个小游戏#
来源:互联网 发布:网络正规兼职写手 编辑:程序博客网 时间:2024/05/19 23:55
#密码输入三次错误输入限制 password_list = ['####','12345'] def account_login(): cishu = 3; while cishu >0: password = input ('password:'); password_correct = password ==password_list[-1]; password_reset = password == password_list[0]; if password_correct: print('login right!'); elif password_reset: new_password = input('Enter a new password:'); password_list.append(new_password); print('your password has changed successfully!'); account_login(); else: print('wrong login'); cishu = cishu-1; print(cishu,'times left'); else: print('Your account has ben suspended'); account_login(); output password:34343434 wrong login 2 times left password:34334 wrong login 1 times left password:34334 wrong login 0 times left Your account has ben suspended Process finished with exit code 0 #Python 编写一个小游戏! import random; def roll_dice(numbers=3,points=None): #随机的三个数 print('<<<<<<<<<<<<<<<<ROLL THE DICE!>>>>>>>>>>>>>>>'); if points is None: points = []; while numbers >0: point = random.randrange(1,7); points.append(point); numbers-=1; return points; def roll_result(total): isBig = 11<= total <= 18; isSmall = 3 <= total <= 10; if isBig: return 'Big'; elif isSmall: return 'Small'; def start_gamw(): print('<<<<<<<<<<<<<<<<GAME STARTS!>>>>>>>>>>>>>>>>>'); choices = ['Big','Small']; your_choices = input('Big or Small:'); if your_choices in choices: points = roll_dice(); total = sum(points); youWin = your_choices == roll_result(total); if youWin: print('The points are',points,'You win'); start_gamw(); else: print('The points are',points,'You lose!'); start_gamw(); else: print('Invalid Words'); start_gamw(); start_gamw();
0 0
- #Python 初学之二编写一个小游戏#
- 二、python笔记之用python做一个小游戏
- Python编写微信打飞机小游戏(二)
- Pygame:编写一个小游戏
- python的一个小游戏之五子棋
- Python学习之二【初学Python】
- COM初学(二) 编写和使用一个简单的COM
- 一个python 小游戏
- 使用python进行小游戏编写
- Python编写打飞机小游戏
- 初学python之基础详解(二)
- python 小游戏 之 汉诺塔
- Python初学(二)
- 初学python二:数据类型
- 一个python写的小游戏
- [初学python]编写冒泡排序
- 使用Android 编写2048小游戏(二)
- Python编写微信打飞机小游戏(一)
- HttpURLConnection中connection.getInputStream()报异常FileNotFoundException
- C++变量的声明与定义
- 12月份英语总结
- Asmack 怎么修改用户信息
- 查询 (反连接)
- #Python 初学之二编写一个小游戏#
- lvs 搭建笔记记录
- 买糖ACM
- 西行漫记
- visual studio 编辑文本无法自动补全的解决方案
- overridePendingTransition设定两个activity之间的转场动画没有效果,但不报错! (大神帮帮我吧,代码如下,谢谢)
- 色生心中:人性化的HSL模型
- C++与Java的区别(一):重定义
- 零基础学习java(六)