python有趣的部分
已有 291 次阅读2017-11-10 21:42
|个人分类:有趣代码
开始学习python,亲自动手编的第一个小程序,不知道为什么第一次觉得猜数字也如此有趣,很开心,
分享一下,继续前行。。。。。。
import random
secrit=random.randint(1,100)
temp =input("亲请猜一下我想的数字:")
while temp.isdigit()!=1:
print('抱歉,输入不合法')
temp=input("请重新输入:")
guass = int(temp)
while guass!=secrit:
temp = input("亲你猜错了请重新猜下数字:")
guass = int(temp)
if guass==secrit:
print("那么厉害")
else:
if guass>secrit:
print("大了")
else:
print("小了")
print("游戏结束")