代码拉取完成,页面将自动刷新
同步操作将从 jack2583/PythonExamples 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
from random import randint
from time import sleep
print("Hello Welcome To The Guess Game!")
sleep(1)
print("I\'m Geek! What's Your Name?")
name = input()
sleep(1)
print(f"Okay {name} Let's Begin The Guessing Game!")
a = comGuess = randint(0, 100) # a and comGuess is initialised with a random number between 0 and 100
count = 0
while True: # loop will run until encountered with the break statement(user enters the right answer)
userGuess = int(input("Enter your guessed no. b/w 0-100:")) # user input for guessing the number
if userGuess < comGuess: # if number guessed by user is lesser than the random number than the user is told to guess higher and the random number comGuess is changed to a new random number between a and 100
print("Guess Higher")
comGuess = randint(a, 100)
a += 1
count = 1
elif userGuess > comGuess: # if number guessed by user is greater than the random number than the user is told to guess lower and the random number comGuess is changed to a new random number between 0 and a
print("Guess Lower")
comGuess = randint(0, a)
a += 1
count = 1
elif userGuess == comGuess and count == 0: # the player needs a special reward for perfect guess in the first try ;-)
print("Bravo! Legendary Guess!")
else: #Well, A Congratulations Message For Guessing Correctly!
print("Congratulations, You Guessed It Correctly!")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。