Skip to content

Commit 3250119

Browse files
committed
Adding code, README.md file
1 parent 2d2d94b commit 3250119

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed

Brain Teaser Game/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Brain Teaser Game
2+
3+
This repository contains a simple brain teaser game implemented in Python. The game presents a series of brain teasers, and the player must provide answers to each one. If the player's answer matches the correct answer, they score a point. The game is a fun way to challenge your brain and test your lateral thinking skills.
4+
5+
## How to Play
6+
7+
1. Clone this repository to your local machine:
8+
9+
```bash
10+
git clone https://github.com/your-username/brain-teaser-game.git
11+
```
12+
13+
2. Navigate to the repository's directory:
14+
15+
```bash
16+
cd brain-teaser-game
17+
```
18+
19+
3. Run the game using your Python interpreter:
20+
21+
```bash
22+
python brain_teaser_game.py
23+
```
24+
25+
4. The game will present you with a series of brain teasers, and you'll be prompted to provide your answers. Answer as many questions as you can to score points.
26+
27+
## Brain Teasers Included
28+
29+
The game includes the following brain teasers:
30+
31+
1. "I speak without a mouth and hear without ears. I have no body, but I come alive with the wind. What am I?"
32+
- Correct Answer: an echo
33+
34+
2. "What comes once in a minute, twice in a moment, but never in a thousand years?"
35+
- Correct Answer: the letter 'm'
36+
37+
3. "The more you take, the more you leave behind. What am I?"
38+
- Correct Answer: footsteps
39+
40+
4. "What has keys but can't open locks?"
41+
- Correct Answer: a piano
42+
43+
5. "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?"
44+
- Correct Answer: all the people were married
45+
46+
## Gameplay Example
47+
48+
```
49+
Welcome to the Brain Teaser Game!
50+
Try to answer the following brain teasers:
51+
52+
Question: I speak without a mouth and hear without ears. I have no body, but I come alive with the wind. What am I?
53+
Your Answer: wind
54+
Sorry, the correct answer is 'an echo'.
55+
56+
Question: What comes once in a minute, twice in a moment, but never in a thousand years?
57+
Your Answer: m
58+
Correct!
59+
60+
Question: The more you take, the more you leave behind. What am I?
61+
Your Answer: time
62+
Sorry, the correct answer is 'footsteps'.
63+
64+
Game Over! Your final score: 1
65+
```
66+
67+
## Customization
68+
69+
Feel free to customize the `brain_teasers` list by adding more brain teasers or changing the questions and answers. You can enhance the game further by adding features like a timer, different difficulty levels, or a graphical user interface (GUI).

Brain Teaser Game/script.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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?", "all the people were married"),
10+
]
11+
12+
def play_game():
13+
score = 0
14+
random.shuffle(brain_teasers) # Shuffle the brain teasers for a random order
15+
16+
print("Welcome to the Brain Teaser Game!")
17+
print("Try to answer the following brain teasers:\n")
18+
19+
for question, answer in brain_teasers:
20+
print("Question:", question)
21+
player_answer = input("Your Answer: ").lower()
22+
23+
if player_answer == answer:
24+
print("Correct!\n")
25+
score += 1
26+
else:
27+
print(f"Sorry, the correct answer is '{answer}'.\n")
28+
29+
print("Game Over! Your final score:", score)
30+
31+
if __name__ == "__main__":
32+
play_game()

0 commit comments

Comments
 (0)