用户:铭哥AU4D查看:0 回复:1 评论:0 创建时间:2021-02-08T12:23:56
【作品展示】

【作品介绍】
一起来猜数字趴!打出1~100之间的神秘数字,一共6次机会,看谁猜得对~
【作品源代码】
import random
# 1 to 100
secret = random.randint(1, 100)
guess = 0
tries = 0
print("AHOY! I'm the Dread Pirate Roberts, and I have a secret!")
print("It is a number from 1 to 100. I'll give you 6 tries.")
while (guess != secret and tries < 6):
guess = int(input("What's yer guess? "))
if (guess < secret):
print('Too low,ye scurvy dog!')
elif (guess > secret):
print('Too high,landlubber!')
else:
pass
tries = (tries + 1)
if (guess == secret):
print('Avast!Ye got it! Found my secret,ye did!')
else:
print('No more guesses! Better luck next time, matey!')
print('The secret number was', secret)
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn