我的第一个Python游戏
2016-03-12 14:50
405 查看
以下是我的第一个Python游戏。
有更好玩的功能请不吝赐教。
运行图片:
import random def guess(): secret = random.randint(0, 99)#Set secret number global user tries = 0 guess = 0 #Words print print"AHOY!I'm the Dread Pirate Roberts, and I have a secret." print"It's a number from 1 to 99, I'll give you 6 tries." #Loop while guess != secret and tries < 6: guess = int(raw_input("What's yer guess, "+user+"?"))#input #Check if guess > secret: print"Too high, landlubber!" elif guess < secret: print"Too low, ye scurvy dog!" tries += 1 if guess == secret: #Print print"Avast!You got it!Found my secret ye did!" else: #Print print"= GAME OVER =" print"No more gusses!Better luck next time, matey!" print"SECRET NUMBER: "+str(secret) def set_user(): global user #Set user user = raw_input("User: ") guess() set_user()
有更好玩的功能请不吝赐教。
运行图片:
相关文章推荐
- python练习
- python callable 函数
- python-Day7
- Python+MoneyRunner+Java实现计算器功能自动化
- Python Multinomial Logistics 实现MNIST分类
- 【零基础入门学习Python笔记012】一个打了激素的数组3
- Python标准库:内置函数bytearray([source[, encoding[, errors]]])
- python atexit
- Python之getopt模块
- python安装教程(Win8环境)
- 个人错误代码集锦(Python语言)
- 朴素贝叶斯
- python3 字典属性
- Python heap - priority queue
- python with as用法
- Handwriting Number Recognition Using Python 2.7.11
- 使用Python内置的模块与函数进行不同进制的数的转换
- Python缓存机制介绍
- python+selenium 自动化测试webui
- Python语言的面相对象编程方式初步学习