Вопрос пользователя:
Ответ нейросети:
Пример реализации игры на языке Python:
import random
def is_even(num):
return num % 2 == 0
def play_game():
print("Welcome to the Brain Games!")
name = input("May I have your name? ")
print("Hello, {}!".format(name))
print("Answer 'yes' if the number is even, otherwise answer 'no'.")
correct_answers = 0
while correct_answers < 3:
num = random.randint(1, 100)
print("Question:", num)
answer = input("Your answer: ")
if (is_even(num) and answer == "yes") or (not is_even(num) and answer == "no"):
print("Correct!")
correct_answers += 1
else:
print("'{}' is wrong answer ;(. Correct answer was '{}'.".format(answer, "yes" if is_even(num) else "no"))
print("Let's try again, {}!".format(name))
correct_answers = 0
print("Congratulations, {}!".format(name))
play_game()
Пример работы программы:
Welcome to the Brain Games!
May I have your name? Bill
Hello, Bill!
Answer 'yes' if the number is even, otherwise answer 'no'.
Question: 15
Your answer: yes
'yes' is wrong answer ;(. Correct answer was 'no'.
Let's try again, Bill!
Question: 8
Your answer: yes
Correct!
Question: 33
Your answer: no
Correct!
Question: 42
Your answer: yes
Correct!
Congratulations, Bill!
Напишите нам, если в вопросе есть ваши персональные данные ([email protected])
Обратите внимание: ответы, предоставляемые искусственным интеллектом, могут не всегда быть точными. Не рассчитывайте на них в критически важных областях, таких как медицина, юриспруденция, финансы или в вопросах, связанных с безопасностью. Для важных решений всегда обращайтесь к квалифицированным специалистам. Администрация сайта не несет ответственности за контент, сгенерированный автоматически.