← Back to Python Course | Chapter 14: Advanced Python & Tools | Lesson 15 of 15

Python Mini Projects

Mini projects छोटे, पूरे programs हैं जैसे calculator या guessing game, जो आपने जो सीखा है उसे एक साथ जोड़ते हैं। यह हर हिस्से के बारे में सीखने के बाद एक छोटा model बनाने जैसा है।

Simple Calculator

एक terminal-based calculator user input, string-to-number conversion, और operation चुनने के लिए conditional logic को एक साथ जोड़ता है -- यह एक compact project है जो एक साथ कई fundamentals (input parsing, arithmetic, bad input के लिए error handling) practice कराता है।

उदाहरण: Simple Calculator

python
def calculate(a, b, op):
    if op == "+":
        return a + b
    elif op == "-":
        return a - b
    return None  # unrecognized operator

print(calculate(5, 3, "+"))

Word Density Counter

एक word-frequency counter input text को अलग-अलग words में split करता है और dictionary (या collections.Counter) से हर word कितनी बार आता है यह गिनता है, यह string processing की एक practical exercise है जो असली documents या user-submitted text analyze करने तक naturally scale हो जाती है।

उदाहरण: Word Density Counter

python
from collections import Counter
text = "the cat sat on the mat"
counts = Counter(text.split())  # tallies how often each word appears
print(counts)

Custom Password Generator

एक password generator random module का इस्तेमाल करके randomly चुने गए letters, digits और symbols की एक string को, चाहे गई length की एक secure key में जोड़ता है -- यह string building को random selection के साथ practice करने के लिए एक अच्छा project है।

उदाहरण: Custom Password Generator

python
import random
import string

random.seed(1)
chars = string.ascii_letters + string.digits  # pool of characters to choose from
password = "".join(random.choice(chars) for _ in range(8))  # 8 random characters joined together
print(password)

Text Guessing Game

एक number-guessing game एक random target number चुनता है और एक loop के अंदर बार-बार player के guesses की उससे तुलना करता है, सही number मिलने तक higher/lower feedback देता है -- यह loops, conditionals और user interaction की एक सरल पर पूरी exercise है।

उदाहरण: Text Guessing Game

python
import random

random.seed(1)
target = random.randint(1, 10)  # the number the player is trying to guess
guess = 5
if guess < target:
    print("Higher")
elif guess > target:
    print("Lower")
else:
    print("Correct!")

Basic File Organizer

एक file organizer script किसी directory के filenames scan करती है, हर एक की extension inspect करती है, और files को type के हिसाब से subfolders में sort करती है -- यह एक practical automation project है जो os/pathlib modules को असली filesystem data पर basic string handling के साथ जोड़ता है।

उदाहरण: Basic File Organizer

python
import os

os.makedirs("demo_files/images", exist_ok=True)
with open("demo_files/photo.jpg", "w") as f:
    f.write("fake image data")

for filename in os.listdir("demo_files"):
    if filename.endswith(".jpg"):  # sorts by file extension
        print(filename, "-> images/")
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.