Amazing-Python-Scripts
36 строк · 1.2 Кб
1import random2
3# Define a list of brain teasers as tuples (question, answer)
4brain_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
14def play_game():15score = 016# Shuffle the brain teasers for a random order17random.shuffle(brain_teasers)18
19print("Welcome to the Brain Teaser Game!")20print("Try to answer the following brain teasers:\n")21
22for question, answer in brain_teasers:23print("Question:", question)24player_answer = input("Your Answer: ").lower()25
26if player_answer == answer:27print("Correct!\n")28score += 129else:30print(f"Sorry, the correct answer is '{answer}'.\n")31
32print("Game Over! Your final score:", score)33
34
35if __name__ == "__main__":36play_game()37