|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import random
secret1 = random.randint(1,100)
secret2 = random.randint(1,10)
b = secret2
print("Let's play a game")
temp = input("Guess a number and see what'll happen")
a = int(temp)
if a == secret1:
print("I have to admit your rightness")
print("WTF handsome")
else:
if a > secret1:
print("Dont thou think it too bulky?")
print("Ohhhhhhhh")
b = b+1
else:
print("just like your penis")
print("Fuck it")
b = b+1
while a != secret1 and b < 10:
temp = input("Wrong number")
a = int(temp)
if a == secret1:
print("I have to admit your rightness")
print("WTF handsome")
else:
if a > secret1:
print("Dont thou think it too bulky?")
print("Ohhhhhhhh")
b = b+1
else:
print("just like your penis")
print("Fuck it")
b = b+1
print("Time is up")
需要做什么改进
基本都给你加了注释,看不懂就再问吧
- import random
- #删掉了很多重复代码
- secret1 = random.randint(1,100)
- secret2 = random.randint(1,9)#至少一次机会
- #初始化ab
- b = 0
- a = 0
- while a != secret1 and b < 10:
- try:#输入错误检测
- if b == 0:#判断是否是第一次猜,下面如果要针对第一次猜数字改变print的内容,可以用同样的方法
- a = int(input("Guess a number and see what'll happen:"))
- else:
- a = int(input("Wrong number"))
- if a == secret1:
- print("I have to admit your rightness")
- print("WTF handsome")
- else:
- if a > secret1:
- print("Dont thou think it too bulky?")
- print("Ohhhhhhhh")
- else:
- print("just like your penis")
- print("Fuck it")
- b = b+1#b放在这就只用一次就行了
- except:#输入错误时反馈
- print("请输入数字")
- #进行下一次循环
- continue
- print("Time is up")
复制代码
|
|