您的位置:首页 > 编程语言 > Python开发

用Python写一个猜数字小游戏

2015-10-25 23:14 597 查看
突发奇想

#coding=utf-8
import random
num = random.randint(0,10)

t = input("please input a number from 0~10:")
n=0
while(t!=num and n<2):
if(t != num):
print('Idiot,It is wrong,now you have '+(str)(2-n)+'chances!')
n=n+1
t = input('Guess again:')
if(n==2):
print('Idiot,you have no chance ~')
else:
print 'Idiot,You win!'
print "Game over"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python 游戏