提问人:Keith Hill 提问时间:11/16/2023 更新时间:11/16/2023 访问量:18
隐藏的python区域调试
Hidden python area debugging
问:
因此,我创建了一个代码来响应某些名称输入,然后为那个人说些什么。然后它会问你 3.55x3.55= 如果输入正确答案 12.6025,那么它会说正确。如果它错了,它会说错了,我期望你更好。在此之后,如果您输入 override5555,它将为您提供支持。
我试图通过输入“overrideKeith_”来添加另一个可访问的隐藏区域。这个区域是一个猜谜游戏,但它不会忽略它,所以它会自动打开它。 代码是
import webbrowser as wb
import ctypes
import random
print("Hello, what is your first name in lowercase")
print("Hint, at the end type in override5555")
name = input()
if name == "keith":
print("you are the awesome creator of this code")
elif name == "chad":
print("you are great at sports")
elif name == "kurt":
print("wow you are the fabled nerd king, just kidding you are very smart")
elif name == "nikolai":
print("You are great at hockey and own many ferraris")
elif name == "jordan":
print("You are very, very buff.")
elif name == "bryden":
print("You are a great friend who always gets swishes")
elif name == "anthony":
print("you are a very kind, and caring person.")
elif name == "kieran":
print("you are a legendary coder")
elif name == "reuben":
print("You wish you could code")
elif name == "paulina":
print("You are the greatest teacher ever.")
elif name == "paulena":
print("You are the greatest teacher ever.")
elif name == "Mrs. Sproule":
print("You are the greatest teacher ever.")
elif name == "failure":
print("You must be Declan")
else:
print("Hello")
print(name)
print("do you know what 3.55x3.55=?")
answer = input()
if answer == "12.6025":
print("correct")
else:
print("wrong, I expected better of you.")
anything = input()
if anything == "override5555":
wb.open('https://r.mtdv.me/pytube')
if anything == "Keith_":
print(" override successful")
command = input()
if command == "command 1":
attempts_list = []
def show_score():
if not attempts_list:
print('There is currently no high score, it\'s yours for the taking!')
else:
print(f'The current high score is {min(attempts_list)} attempts')
def start_game():
attempts = 0
rand_num = random.randint(1, 10)
print('Hello traveler! Welcome to the game of guesses!')
player_name = input('What is your name? ')
wanna_play = input(f'Hi, {player_name}, would you like to play the guessing game? (Enter Yes/No): ')
if wanna_play.lower() != 'yes':
print('That\'s cool, Thanks!')
exit()
else:
show_score()
while wanna_play.lower() == 'yes':
try:
guess = int(input('Pick a number between 1 and 10: '))
if guess < 1 or guess > 10:
raise ValueError('Please guess a number within the given range')
attempts += 1
attempts_list.append(attempts)
if guess == rand_num:
print('Nice! You got it!')
print(f'It took you {attempts} attempts')
wanna_play = input('Would you like to play again? (Enter Yes/No): ')
if wanna_play.lower() != 'yes':
print('That\'s cool, have a good one!')
break
else:
attempts = 0
rand_num = random.randint(1, 10)
except ValueError as e:
print(e)
start_game()
答:
0赞
piotre10
11/16/2023
#1
我想你只需要start_game放在if语句下(不确定它是否是你想要的确切行为),把你的函数定义放在顶部也是个好主意:
import webbrowser as wb
import ctypes
import random
def show_score():
(...)
def start_game():
(...)
print("Hello, what is your first name in lowercase")
print("Hint, at the end type in override5555")
name = input()
(...)
print(name)
print("do you know what 3.55x3.55=?")
answer = input()
(...)
anything = input()
if anything == "override5555":
wb.open('https://r.mtdv.me/pytube')
if anything == "Keith_":
print(" override successful")
command = input()
if command == "command 1":
attempts_list = []
if anything == "override5555Keith_":
start_game()
评论
"overrideKeith_"