DAY 52 — 60 DAY PYTHON CHALLENGE
Story Generator
Python mein Story Generator banao — Hindi mein step by step
Advertisement
Project kya hai?
Day 52 ka project hai Story Generator!
Yeh project banane se aap Python ke important concepts
practice kar payenge. Neeche complete code hai — copy karo aur chalao!
Complete Python Code
python — story.py
import random
heroes = ["Arjun", "Priya", "Ravi", "Ananya", "Dev", "Sakshi"]
places = ["Mumbai ki galiyon mein", "Jaipur ke qile mein", "Kerala ke junglon mein", "Shimla ki pahariyon mein"]
problems = ["ek rahasya tha", "ek khazana mila", "ek dost kho gaya", "ek mushkil samne aayi"]
skills = ["Python coding se", "dimag lagakar", "team work se", "himmat se"]
helpers = ["ek purane dost ne", "ek anjaan insaan ne", "technology ne", "ek bacche ne"]
endings = ["sab khush ho gaye!", "jeet mili!", "nayi dosti hui!", "duniya badal gayi!"]
def generate_story():
hero = random.choice(heroes)
place = random.choice(places)
problem = random.choice(problems)
skill = random.choice(skills)
helper = random.choice(helpers)
ending = random.choice(endings)
lines = [
"=== EK BAAR KI BAAT HAI ===",
"",
f"{hero} {place} rehte the.",
f"Ek din wahan {problem}.",
f"{hero} ne {skill} kaam kiya.",
f"Tabhi {helper} madad ki.",
f"Aur ant mein... {ending}",
"",
"=== THE END ==="
]
story = "\n".join(lines)
return story, hero
print("=== Story Generator ===")
print("Enter dabao = Nayi kahani | q = Quit")
count = 0
while True:
cmd = input("\n[Enter/q]: ").strip()
if cmd.lower() == "q":
break
story, hero = generate_story()
count += 1
print(f"\nKahani #{count}: {hero} ki adventure!")
input("Sunne ke liye Enter dabao...")
print(story)
OUTPUT
[Enter/q]: Kahani #1: Dev ki adventure! Sunne ke liye Enter dabao... === EK BAAR KI BAAT HAI === Dev Mumbai ki galiyon mein rehte the. Ek din wahan ek khazana mila. Dev ne Python coding se kaam kiya. Tabhi ek purane dost ne madad ki. Aur ant mein... jeet mili! === THE END ===
Code kaise kaam karta hai?
Multiple lists se random elements pick hote hain. f-string se story template fill hoti hai. Har baar nai story generate hoti hai - infinite combinations!
Advertisement
📋 Project ka Introduction
Story Generator Python ka Day 52 ka project hai. Is project mein aap Python ke important concepts practice karenge jo real-world applications mein bahut use hote hain.
Yeh project beginners ke liye design kiya gaya hai lekin kaafi concepts cover karta hai. Step by step samjho, code chalao, aur khud modify karke practice karo.
Is tarah ke projects banane se aapka Python confidence badh jaata hai aur aap asli problems solve karna seekh jaate hain. Chaliye code samjhte hain!
Yeh project beginners ke liye design kiya gaya hai lekin kaafi concepts cover karta hai. Step by step samjho, code chalao, aur khud modify karke practice karo.
Is tarah ke projects banane se aapka Python confidence badh jaata hai aur aap asli problems solve karna seekh jaate hain. Chaliye code samjhte hain!
🧠 Is Project mein kya seekhoge?
Yeh project banate waqt aap ye Python concepts use karoge:
| Concept | Kya karta hai |
|---|---|
Variables | Data store karna |
Functions | Reusable code blocks |
Loops | Repeat karna |
Conditions | Decisions lena |
Input/Output | User se interact karna |
📝 Code kaise kaam karta hai — Step by Step
Neeche code ki poori logic step-by-step samjhayi gayi hai:
- Problem samjho: Story Generator mein kya karna hai
- Required variables aur data structures decide karo
- Logic step-by-step likhó
- Code mein implement karo
- Test karo aur bugs fix karo
⚠️ Common Mistakes — Bhool mat jaana!
Beginners yeh galtiyan aksar karte hain — dhyan rakho:
- ⚠️ Indentation sahi rakho — Python mein spaces matter karti hain
- ⚠️ Variables ko use se pehle define karo
- ⚠️ Input ko int()/float() mein convert karo agar number chahiye
- ⚠️ Edge cases handle karo — kya hoga agar user galat input de?
🏋️ Practice Exercises — Aage badho!
Yeh project complete karne ke baad in exercises se practice karo:
- 💡 Story Generator mein naya feature add karo
- 💡 Code ko functions mein refactor karo
- 💡 Error handling improve karo
- 💡 File mein data save karo
❓ Aksar Pooche Jane Wale Sawal (FAQ)
Q: Story Generator project kyon banana chahiye?
A: Har project ek naya concept sikhata hai. Practice se hi Python fluent aati hai.
A: Har project ek naya concept sikhata hai. Practice se hi Python fluent aati hai.
Q: Code run nahi ho raha?
A: Indentation check karo, syntax errors dekho, variables define hain ya nahi check karo.
A: Indentation check karo, syntax errors dekho, variables define hain ya nahi check karo.
Q: Kaise improve karein?
A: Pehle basic version complete karo, phir ek ek feature add karte jao.
A: Pehle basic version complete karo, phir ek ek feature add karte jao.