if __name__ == '__main__':
import time
import random
play_it = input('do you want to play it.(\'y\' or \'n\')')
while play_it == 'y':
c = input('input a character:\n')
i = random.randint(0, 2 ** 32) % 100
print('please input number you guess!')
start = time.process_time()
a = time.time()
guess = int(input('input your guess:\n'))
while guess != i:
if guess > i:
print('please input a little smaller')
guess = int(input('input your guess:\n'))
else:
print('please input a little bigger')
guess = int(input('input your guess:\n'))
end = time.process_time()
b = time.time()
var = (end - start) / 18.2
print(var)
print(f'It took you {b - a} seconds')
if var < 15:
print('you are very clever!')
elif var < 25:
print('you are normal!')
else:
print('you are stupid!')
print('Congradulations')
print('The number you guess is %d' % i)
play_it = input('do you want to play it.(\'y\' or \'n\')')
#!/ usr / bin / python
#-*-编码:UTF-8-*-
如果 __name__ == ' __main__ ':
导入 时间
import random
play_it = raw_input ('您要播放吗((' y '或\' n \')' ),
而 play_it == 'y':
c = raw_input ('输入字符:\ n ' )
i = random。randint (0 ,2** 32 )%100
打印 '请输入您猜的输入数字:\ n '
开始= 时间。时钟()
a = 时间。time ()
guess = int (raw_input ('输入您的猜测:\ n ' ))
而 guess != i:
如果 guess > i:
打印 '请输入小一点的'
guess = int(raw_input ('输入您的猜测:\ n ' ))
否则:
打印 '请输入更大一点'
guess = int (raw_input ('输入您的猜测:\ n ' ))
end = time。时钟()
b = 时间。time ()
var = (结束-开始) / 18.2
print var
#
如果 var < 15:
打印 ' 花了您%6.3秒'%time.difftime(b,a)):打印'您非常聪明!'
elif var < 25:
打印 “你很正常!”
else:
打印 “你很蠢!”
打印 “Congradulations”
打印 “你猜的数字是%d”%我
play_it = 的raw_input (“你想打它。” )
以上实例输出结果为:
你想玩吗。('y'或'n')y
输入一个字符:
5
请输入您猜出的数字:
输入您的猜测:
60
……
请输入大一点
输入您的猜测:
29
请输入小一点
输入您的猜测::
2828
3.81868131868e-053.81868131868e-05
你很聪明!!
成绩成绩
你猜的数字是28你猜的数字是28
你想玩吗你想玩吗。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。