Skip to content

Commit 3f99642

Browse files
Merge pull request #175 from Indrayani11-15/add-word-scramble-game
Added new game of word scramble with its web app functionality
2 parents 1270069 + 3d4f8d5 commit 3f99642

5 files changed

Lines changed: 543 additions & 12 deletions

File tree

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
[![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
88
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
9-
[![Projects](https://img.shields.io/badge/projects-24-orange.svg)]()
9+
[![Projects](https://img.shields.io/badge/projects-21-orange.svg)]()
1010
[![Code Scanning](https://img.shields.io/badge/CodeQL-enabled-brightgreen.svg)]()
1111

1212
**🚀 Perfect for beginners | 💡 Learn by doing | 🎨 Beautiful UI | ⚡ Zero setup required**
@@ -178,6 +178,17 @@ python games/FLAMES-Game/FLAMES-Game.py
178178
</td>
179179
<td width="50%">
180180

181+
#### 🔤 Word Scramble Game
182+
Unscramble shuffled words before attempts run out!
183+
- 🧩 Random programming-themed words
184+
- 💡 Helpful hint for every round
185+
- 🔥 Score and streak tracking
186+
```bash
187+
python games/Word-Scramble-Game/Word-Scramble-Game.py
188+
```
189+
190+
</td>
191+
</tr>
181192

182193
<tr>
183194
<td width="50%">
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import random
2+
3+
4+
WORDS = [
5+
("python", "A friendly programming language used across this project."),
6+
("variable", "A named place where a program stores a value."),
7+
("function", "Reusable code that performs one clear task."),
8+
("keyboard", "The device you use to type your answers."),
9+
("algorithm", "A step-by-step method for solving a problem."),
10+
("database", "An organized collection of information."),
11+
("developer", "Someone who builds software."),
12+
("network", "Connected computers that can share data."),
13+
("software", "Programs and apps that run on a computer."),
14+
("internet", "The global network that connects websites and services."),
15+
]
16+
17+
18+
def scramble_word(word):
19+
letters = list(word)
20+
scrambled = word
21+
22+
while scrambled == word and len(word) > 3:
23+
random.shuffle(letters)
24+
scrambled = "".join(letters)
25+
26+
return scrambled
27+
28+
29+
def play_round(word, hint, score, streak):
30+
attempts = 3
31+
scrambled = scramble_word(word)
32+
33+
print("\n" + "-" * 50)
34+
print(f"Scrambled word: {scrambled.upper()}")
35+
print(f"Hint: {hint}")
36+
print(f"Attempts: {attempts}")
37+
38+
while attempts > 0:
39+
guess = input("\nYour guess: ").strip().lower()
40+
41+
if not guess.isalpha():
42+
print("Please enter letters only.")
43+
continue
44+
45+
if guess == word:
46+
points = attempts * 10 + streak * 5
47+
print(f"Correct! The word was {word.upper()}.")
48+
print(f"You earned {points} points.")
49+
return score + points, streak + 1
50+
51+
attempts -= 1
52+
if attempts > 0:
53+
print(f"Not quite. Attempts left: {attempts}")
54+
55+
print(f"Out of attempts! The word was {word.upper()}.")
56+
return score, 0
57+
58+
59+
def main():
60+
print("=" * 50)
61+
print("WELCOME TO WORD SCRAMBLE GAME")
62+
print("=" * 50)
63+
print("Unscramble each word. You get 3 attempts per round.")
64+
print("Type 'quit' between rounds to stop playing.")
65+
66+
score = 0
67+
streak = 0
68+
words = WORDS[:]
69+
random.shuffle(words)
70+
71+
while True:
72+
if not words:
73+
words = WORDS[:]
74+
random.shuffle(words)
75+
76+
word, hint = words.pop()
77+
score, streak = play_round(word, hint, score, streak)
78+
79+
print("\n" + "=" * 50)
80+
print(f"Score: {score}")
81+
print(f"Current streak: {streak}")
82+
print("=" * 50)
83+
84+
choice = input("\nPress Enter for next word or type 'quit': ").strip().lower()
85+
if choice == "quit":
86+
break
87+
88+
print("\nThanks for playing Word Scramble!")
89+
print(f"Final score: {score}")
90+
91+
92+
if __name__ == "__main__":
93+
main()

web-app/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ An interactive web application showcasing Python mini projects with beautiful vi
1818
- **Dice Rolling** - 3D rolling animation with realistic dice faces
1919
- **Coin Flip** - Spinning coin with heads/tails statistics
2020
- **Number Guessing** - Interactive guessing with smart hints
21-
- **Hangman** - Classic word game
22-
- **FLAMES** - Relationship calculator
23-
- **Simon Says** - Memory Game
24-
- **Spot the Difference** - Visual puzzle game with dynamic scenes
21+
- **Hangman** - Classic word game with onscreen keyboard
22+
- **Word Scramble** - Unscramble shuffled words with hints and score tracking
23+
- **FLAMES** - Relationship calculator
2524

2625
### 🔢 Math Tools
2726
- **Fibonacci Series** - Visual sequence with golden spiral
@@ -92,7 +91,7 @@ Edit CSS variables in `css/styles.css`:
9291
```
9392

9493
### Add New Projects
95-
1. Add HTML template function in `js/projects-extended.js`
94+
1. Add HTML template function in `js/projects.js`
9695
2. Add initialization function
9796
3. Add card in `index.html` projects grid
9897
4. Link functions in `getProjectHTML()` and `initializeProject()`

web-app/index.html

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,19 @@ <h3>Hangman</h3>
9999
<button class="btn-play">Try It</button>
100100
</div>
101101

102-
<div class="project-card" data-category="games" data-project="flames" data-tags="game,string,fun,relationship">
103-
<div class="card-icon">💖</div>
104-
<h3>FLAMES Game</h3>
105-
<p>Discover your relationship status!</p>
106-
<button class="btn-play">Try It</button>
107-
</div>
102+
<div class="project-card" data-category="games" data-project="word-scramble">
103+
<div class="card-icon">&#128292;</div>
104+
<h3>Word Scramble</h3>
105+
<p>Unscramble words before attempts run out!</p>
106+
<button class="btn-play">Play Now</button>
107+
</div>
108+
109+
<div class="project-card" data-category="games" data-project="flames">
110+
<div class="card-icon">💖</div>
111+
<h3>FLAMES Game</h3>
112+
<p>Discover your relationship status!</p>
113+
<button class="btn-play">Play Now</button>
114+
</div>
108115

109116
<div class="project-card" data-category="games" data-project="password-forge">
110117
<div class="card-icon">🔐</div>

0 commit comments

Comments
 (0)