Amazing-Python-Scripts

Форк
0
36 строк · 1.2 Кб
1
import random
2

3
# Define a list of brain teasers as tuples (question, answer)
4
brain_teasers = [
5
    ("I speak without a mouth and hear without ears. I have no body, but I come alive with the wind. What am I?", "an echo"),
6
    ("What comes once in a minute, twice in a moment, but never in a thousand years?", "the letter 'm'"),
7
    ("The more you take, the more you leave behind. What am I?", "footsteps"),
8
    ("What has keys but can't open locks?", "a piano"),
9
    ("You see a boat filled with people. It has not sunk, but when you look again you don’t see a single person on the boat. Why?",
10
     "all the people were married"),
11
]
12

13

14
def play_game():
15
    score = 0
16
    # Shuffle the brain teasers for a random order
17
    random.shuffle(brain_teasers)
18

19
    print("Welcome to the Brain Teaser Game!")
20
    print("Try to answer the following brain teasers:\n")
21

22
    for question, answer in brain_teasers:
23
        print("Question:", question)
24
        player_answer = input("Your Answer: ").lower()
25

26
        if player_answer == answer:
27
            print("Correct!\n")
28
            score += 1
29
        else:
30
            print(f"Sorry, the correct answer is '{answer}'.\n")
31

32
    print("Game Over! Your final score:", score)
33

34

35
if __name__ == "__main__":
36
    play_game()
37

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.