Build real-world projects ā the best way to learn!
Add, subtract, multiply, divide ā take input from user and show result
Computer chooses a random number, you have to guess it!
Multiple choice quiz ā track score and show result
Generate random strong passwords with custom length
# š§® Simple Calculator
def calculator():
print("=" * 30)
print("š§® PyMaster Calculator")
print("=" * 30)
while True:
print("\nOptions: + - * / ** % quit")
op = input("Operation: ").strip()
if op == "quit":
print("Bye! š"); break
try:
a = float(input("Number 1: "))
b = float(input("Number 2: "))
if op == "+": result = a + b
elif op == "-": result = a - b
elif op == "*": result = a * b
elif op == "/":
if b == 0:
print("ā Cannot divide by zero!"); continue
result = a / b
elif op == "**": result = a ** b
elif op == "%": result = a % b
else:
print("ā Invalid operation!"); continue
print(f"ā
{a} {op} {b} = {result}")
except ValueError:
print("ā Please enter valid numbers!")
calculator()
# š² Number Guessing Game
import random
def guessing_game():
secret = random.randint(1, 100)
attempts = 0
max_attempts = 10
print("š² Number Guessing Game!")
print(f"Guess between 1-100 (Max {max_attempts} tries)")
print("-" * 30)
while attempts < max_attempts:
try:
guess = int(input(f"Attempt {attempts+1}: "))
attempts += 1
if guess == secret:
print(f"š Correct! {secret} in {attempts} attempts!")
return
elif guess < secret:
print("š Too low! Go higher!")
else:
print("š Too high! Go lower!")
except ValueError:
print("Enter a valid number!")
print(f"š¢ Game Over! Number was {secret}")
guessing_game()
Add, delete, complete tasks ā save to file
Automatically organize files into folders by type
Add, search, update, delete contacts ā save/load from JSON
# š To-Do App with File Storage
import json, os
FILE = "todos.json"
def load_todos():
if os.path.exists(FILE):
with open(FILE) as f: return json.load(f)
return []
def save_todos(todos):
with open(FILE, "w") as f: json.dump(todos, f, indent=2)
def show_todos(todos):
if not todos:
print("š No tasks yet!"); return
print("\nš Your Tasks:")
for i, t in enumerate(todos, 1):
status = "ā
" if t["done"] else "ā¬"
print(f" {i}. {status} {t['task']}")
def main():
todos = load_todos()
while True:
print("\n--- To-Do Menu ---")
print("1. View 2. Add 3. Complete 4. Delete 5. Quit")
ch = input("Choose: ")
if ch == "1": show_todos(todos)
elif ch == "2":
task = input("New task: ")
todos.append({"task": task, "done": False})
save_todos(todos)
print(f"ā
Added: {task}")
elif ch == "3":
show_todos(todos)
idx = int(input("Complete #: ")) - 1
if 0 <= idx < len(todos):
todos[idx]["done"] = True
save_todos(todos); print("Done! ā
")
elif ch == "4":
show_todos(todos)
idx = int(input("Delete #: ")) - 1
if 0 <= idx < len(todos):
removed = todos.pop(idx)
save_todos(todos)
print(f"šļø Deleted: {removed['task']}")
elif ch == "5": print("Bye! š"); break
main()
# š Automatic File Organizer
import os, shutil
def organize_folder(folder_path):
file_types = {
"Images": [".jpg",".jpeg",".png",".gif",".svg",".webp"],
"Documents": [".pdf",".doc",".docx",".txt",".xlsx",".pptx"],
"Videos": [".mp4",".mkv",".avi",".mov"],
"Music": [".mp3",".wav",".flac",".aac"],
"Code": [".py",".js",".html",".css",".java",".cpp"],
"Archives": [".zip",".rar",".7z",".tar"],
}
for filename in os.listdir(folder_path):
filepath = os.path.join(folder_path, filename)
if os.path.isdir(filepath): continue
ext = os.path.splitext(filename)[1].lower()
dest_folder = "Others"
for category, extensions in file_types.items():
if ext in extensions:
dest_folder = category; break
dest_path = os.path.join(folder_path, dest_folder)
os.makedirs(dest_path, exist_ok=True)
shutil.move(filepath, os.path.join(dest_path, filename))
print(f"š¦ {filename} ā {dest_folder}/")
print("ā
All files organized!")
# Usage: organize_folder("C:/Users/you/Downloads")
Build a simple web application with Flask
Train Machine Learning model and make predictions
Automatically extract data from websites
# š Simple Flask Web App
# pip install flask
from flask import Flask, render_template_string
app = Flask(__name__)
HTML = """
<!DOCTYPE html>
<html>
<head><title>PyMaster App</title>
<style>
body { font-family: sans-serif; text-align: center;
padding: 50px; background: #1a1a2e; color: white; }
h1 { font-size: 3rem; }
.btn { padding: 12px 24px; background: #6366f1; color: white;
border: none; border-radius: 8px; font-size: 1rem;
cursor: pointer; text-decoration: none; }
</style>
</head>
<body>
<h1>š PyMaster Flask App</h1>
<p>Welcome! This is built with Python Flask.</p>
<a href="/about" class="btn">About</a>
</body>
</html>
"""
@app.route("/")
def home():
return render_template_string(HTML)
@app.route("/about")
def about():
return "<h1>About PyMaster</h1><p>A Python learning platform!</p>"
if __name__ == "__main__":
app.run(debug=True)
python app.py ā Open http://localhost:5000