├── 32-task-manager ├── tasks.json └── app.py ├── 26-personal-finance-tracker ├── my_finances.txt └── app.py ├── 04-check-char-type └── app.py ├── 01-website-checker └── app.py ├── 0-crash-course ├── 8-error-handling.py ├── 3-input-output.py ├── 1-variables&data-types.py ├── 7-lists&dicts.py ├── 9-builtin-modules.py ├── 6-functions.py ├── 4-conditionals.py ├── 2-basic-operations.py └── 5-loops.py ├── 02-step-counter └── app.py ├── 09-reverse-name └── app.py ├── 03-text-formatter └── app.py ├── 08-random-name-generator └── app.py ├── 06-word-scrambler └── app.py ├── 07-music-recommender └── app.py ├── 05-grade-calculator └── app.py ├── 10-vowel-counter └── app.py ├── 11-coin-flip-game └── app.py ├── 30-tkinter-hello-world └── app.py ├── 14-guess-the-word └── app.py ├── 12-recipe-generator └── app.py ├── 16-countdown-timer └── app.py ├── 13-color-mixer └── app.py ├── 15-guess-the-number └── app.py ├── 31-tkinter-calculator └── app.py ├── 17-calculator └── app.py ├── 24-currency-converter └── app.py ├── 18-related-word-game └── app.py ├── 19-memory-sequence-game └── app.py ├── 21-task-manager └── app.py ├── 33-drawing-app └── app.py ├── 22-simple-chat-bot └── app.py ├── 23-word-counter └── app.py ├── 20-rock-paper-scissors └── app.py ├── 28-pomodoro-timer └── app.py ├── 25-password-generator └── app.py ├── README.md ├── 27-quiz-game └── app.py └── 29-adventure-game └── app.py /32-task-manager/tasks.json: -------------------------------------------------------------------------------- 1 | ["\u2713 Learn python", "\u2713 Learn js", "Learn c++"] -------------------------------------------------------------------------------- /26-personal-finance-tracker/my_finances.txt: -------------------------------------------------------------------------------- 1 | 2025-04-03|-200|rent|dsakdnka 2 | 2025-04-03|+5000|Salary|my salary as a programmer 3 | -------------------------------------------------------------------------------- /04-check-char-type/app.py: -------------------------------------------------------------------------------- 1 | print("📝 CHARACTER TYPE CHECKER 📝") 2 | char = input("Enter a single character: ") 3 | 4 | if char.isalpha(): 5 | print("This is a letter.") 6 | elif char.isdigit(): 7 | print("This is a digit.") 8 | else: 9 | print("This is a special char.") 10 | -------------------------------------------------------------------------------- /01-website-checker/app.py: -------------------------------------------------------------------------------- 1 | print("🔍 WEBSITE URL CHECKER 🔍") 2 | url = input("\nEnter a website URL: ") 3 | 4 | if url.startswith("https://"): 5 | print("🔐 This website uses HTTPS (secure)") 6 | elif url.startswith("http://"): 7 | print("👀 This website uses HTTP (not secure)") 8 | else: 9 | print("❌ This doesn't look like a complete URL") 10 | -------------------------------------------------------------------------------- /0-crash-course/8-error-handling.py: -------------------------------------------------------------------------------- 1 | try: 2 | number = int(input("Enter a number: ")) 3 | result = 10 / number 4 | print(f"10 divided by {number} is {result}") 5 | except ValueError: 6 | print("That's not a valid number!") 7 | except ZeroDivisionError: 8 | print("You cannot divide by zero!") 9 | finally: 10 | print("This piece of code will always run!") 11 | -------------------------------------------------------------------------------- /02-step-counter/app.py: -------------------------------------------------------------------------------- 1 | print("🏃 STEP COUNTER 🏃") 2 | daily_goal = int(input("🤷‍♂️ What is your daily step goal? ")) 3 | current_steps = int(input("✨ How many steps have you taken today? ")) 4 | 5 | remaining = daily_goal - current_steps 6 | if remaining > 0: 7 | print(f"💪 You need {remaining} more steps to reach your goal!") 8 | else: 9 | print( 10 | f"🎉 Congratulations! You've exceeded your goal by {-remaining} steps!") 11 | -------------------------------------------------------------------------------- /09-reverse-name/app.py: -------------------------------------------------------------------------------- 1 | print("🔄 REVERSE NAME GENERATOR 🔄") 2 | 3 | while True: 4 | name = input("\nEnter a name: ") 5 | 6 | if not name: 7 | break 8 | 9 | reversed_name = name[::-1] 10 | print(f"Your reversed name is: {reversed_name}") 11 | print(f"In a parallel universe, they call you {reversed_name.title()}") 12 | 13 | answer = input("\nTry another name? (y/n): ") 14 | if answer != "y": 15 | break 16 | -------------------------------------------------------------------------------- /03-text-formatter/app.py: -------------------------------------------------------------------------------- 1 | print("📢 TEXT CAPITALIZER 📢") 2 | text = input("🤷‍♂️ Enter some text: ") 3 | print("✨ 1. UPPERCASE") 4 | print("👀 2. lowercase") 5 | print("🎉 3. Title Case") 6 | print("🚀 4. Sentence case") 7 | 8 | choice = input("Choose a format (1-4): ") 9 | 10 | if choice == "1": 11 | print(text.upper()) 12 | elif choice == "2": 13 | print(text.lower()) 14 | elif choice == "3": 15 | print(text.title()) 16 | elif choice == "4": 17 | print(text.capitalize()) 18 | -------------------------------------------------------------------------------- /08-random-name-generator/app.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | first_parts = ["Sky", "Star", "Moon", "Sun", "Fire", "Ice"] 4 | last_parts = ["rider", "walker", "hunter", 5 | "seeker", "dancer", "keeper", "singer"] 6 | 7 | print("✨ FANTASY NAME GENERATOR ✨") 8 | 9 | count = int(input("How many names do you want? ")) 10 | 11 | for _ in range(count): 12 | first_name = random.choice(first_parts) 13 | last_name = random.choice(last_parts) 14 | print(f"{first_name}{last_name}") 15 | -------------------------------------------------------------------------------- /06-word-scrambler/app.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | print("🔤 WORD SCRAMBLER 🔤") 4 | 5 | while True: 6 | word = input("\nEnter a word to scramble (or 'quit'):") 7 | if word.lower() == "quit": 8 | print("👋 Goodbye!") 9 | break 10 | 11 | # "everyone" => ["e","v","e","r","y","o","n","e"] 12 | # shuffle => ["y","v","e","r","e","o","n","e"] => join => yvereone 13 | letters = list(word) 14 | random.shuffle(letters) 15 | print(f"Scrambled: {"".join(letters)}") 16 | -------------------------------------------------------------------------------- /07-music-recommender/app.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | print("🎶 MUSIC RECOMMENDER 🎶") 4 | 5 | genres = { 6 | "rock": ["AC/DC", "Queen", "Led Zeppelin"], 7 | "pop": ["Taylor Swift", "Ed Sheeran", "Ariana Grande"], 8 | "hip-hop": ["Kendrick Lamar", "Drake", "J. Cole"], 9 | } 10 | 11 | choice = input("What genre do you like? (rock/pop/hip-hop): ") 12 | 13 | if choice not in genres: 14 | print("😭 Sorry, I don't know that genre.") 15 | else: 16 | print(f"Check out {random.choice(genres[choice])}") 17 | -------------------------------------------------------------------------------- /05-grade-calculator/app.py: -------------------------------------------------------------------------------- 1 | print("📊 GRADE CALCULATOR 📊") 2 | scores = [] 3 | 4 | while True: 5 | score = input("Enter a test score (or 'done'): ") 6 | if score.lower() == "done": 7 | print("👋 Goodbye") 8 | break 9 | 10 | scores.append(float(score)) 11 | average = sum(scores) / len(scores) 12 | print(f"Average score: {average:.1f}") 13 | if average >= 90: 14 | print("Grade: A") 15 | elif average >= 80: 16 | print("Grade: B") 17 | elif average >= 70: 18 | print("Grade: C") 19 | else: 20 | print("Grade: D or F") 21 | -------------------------------------------------------------------------------- /10-vowel-counter/app.py: -------------------------------------------------------------------------------- 1 | print("🔤 VOWEL COUNTER 🔤") 2 | 3 | # Simple syntax 4 | # while True: 5 | # text = input("\nEnter some text (or 'quit'): ") 6 | 7 | # if text.lower() == "quit": 8 | # print("👋 Goodbye!") 9 | # break 10 | 11 | # vowel_count = 0 12 | 13 | # for letter in text.lower(): 14 | # if letter in ["a", "e", "i", "o", "u"]: 15 | # vowel_count += 1 16 | 17 | # print(f"That text has {vowel_count} vowels!") 18 | 19 | 20 | # Advanced syntax 21 | 22 | while True: 23 | text = input("\nEnter some text (or 'quit'): ") 24 | 25 | if text.lower() == "quit": 26 | print("👋 Goodbye!") 27 | break 28 | 29 | vowels = sum(1 for char in text.lower() if char in "aeiou") 30 | print(f"That text has {vowels} vowels!") 31 | -------------------------------------------------------------------------------- /11-coin-flip-game/app.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | print("🎮 COIN FLIP GAME 🎮") 4 | print("Guess heads or tails ✨") 5 | 6 | 7 | while True: 8 | guess = input("\nEnter your guess (heads/tails): ").lower() 9 | 10 | if guess != "heads" and guess != "tails": 11 | print("❌ Please enter 'heads' or 'tails' ❌") 12 | continue # what continue does? it goes back to the start of the loop 13 | 14 | flip = random.choice(["heads", "tails"]) 15 | 16 | print(f"\n🪙 Coin shows {flip}") 17 | 18 | if guess == flip: 19 | print("You won! You guessed correctly. 🎉") 20 | else: 21 | print("😢 Sorry, wrong guess. Try again! 🍀") 22 | 23 | again = input("\n🔄 Play again? (yes/no): ").lower() 24 | if not again.startswith("y"): 25 | print("Goodbye!") 26 | break 27 | -------------------------------------------------------------------------------- /30-tkinter-hello-world/app.py: -------------------------------------------------------------------------------- 1 | import tkinter as tk 2 | 3 | 4 | def say_hello(): 5 | name = name_entry.get() 6 | 7 | if name: 8 | greeting_label.config(text=f"Hello, {name}") 9 | else: 10 | greeting_label.config(text="Hello, World") 11 | 12 | 13 | window = tk.Tk() 14 | window.title("My First Tkinter App") 15 | window.geometry("300x200") 16 | 17 | window.resizable(False, False) 18 | 19 | title_label = tk.Label(window, text="Welcome to TKinter!", font=("Arial", 16)) 20 | title_label.pack(pady=10) 21 | 22 | name_entry = tk.Entry(window, width=20) 23 | name_entry.pack(pady=10) 24 | 25 | hello_button = tk.Button(window, text="Say Hello", command=say_hello) 26 | hello_button.pack(pady=10) 27 | 28 | greeting_label = tk.Label(window, text="", font=("Arial", "12")) 29 | greeting_label.pack(pady=10) 30 | 31 | window.mainloop() 32 | -------------------------------------------------------------------------------- /14-guess-the-word/app.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | print("\n=== 🔤 GUESS THE WORD! 🔤 ===") 4 | print("✨ Unscramble the letters to find the word! ✨") 5 | 6 | words = ["python", "coding", "game", "computer", "fun", "learn"] 7 | 8 | while True: 9 | original_word = random.choice(words) 10 | 11 | # "game" => ["g","a","m","e"] => ["a","g","m","e"] => "agme" 12 | letters = list(original_word) 13 | random.shuffle(letters) 14 | scrambled = "".join(letters) 15 | 16 | print(f"\n Scrambled word: {scrambled}") 17 | 18 | guess = input("🤔 What's the word?: ").lower() 19 | 20 | if guess == original_word: 21 | print("🎉 Congrats! You win!") 22 | else: 23 | print(f"😢 Sorry, the word was: {original_word}") 24 | 25 | again = input("Play again? (y/n): ").lower() 26 | if not again.startswith("y"): 27 | print("Goodbye! 👋") 28 | break 29 | -------------------------------------------------------------------------------- /12-recipe-generator/app.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | print("👩‍🍳 RANDOM RECIPE GENERATOR 👩‍🍳") 4 | 5 | proteins = ["chicken", "beef", "tofu", "fish", "eggs"] 6 | veggies = ["broccoli", "carrots", "spinach", "bell peppers", "mushrooms"] 7 | carbs = ["rice", "pasta", "potatoes", "quinoa", "bread"] 8 | methods = ["baked", "grilled", "stir-fried", "roasted", "sautéed"] 9 | flavors = ["garlic", "lemon", "spicy", "herb", "sweet & sour"] 10 | 11 | 12 | while True: 13 | protein = random.choice(proteins) 14 | veggie = random.choice(veggies) 15 | carb = random.choice(carbs) 16 | method = random.choice(methods) 17 | flavor = random.choice(flavors) 18 | 19 | print( 20 | f"\nYour random recipe: {flavor} {method} {protein} with {veggie} and {carb}") 21 | 22 | if not input("\nGenerate another one? (y/n): ").lower().startswith("y"): 23 | print("👋 Goodbye!") 24 | break 25 | -------------------------------------------------------------------------------- /16-countdown-timer/app.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | print("\n=== ⏱️ COUNTDOWN TIMER ⏱️ ===") 4 | print("✨ Count down from your chosen seconds! ✨") 5 | 6 | while True: 7 | try: 8 | seconds = int(input("\n🤔 Enter seconds to countdown from: ")) 9 | 10 | # validate input 11 | if seconds <= 0: 12 | print("❌ Please enter a positive number.") 13 | continue 14 | 15 | print(f"⏳ Starting countdown from {seconds} seconds!") 16 | 17 | for i in range(seconds, 0, -1): 18 | print(f"⏰ {i} seconds remaining...") 19 | time.sleep(1) 20 | 21 | print("\n🎉 COUNTDOWN COMPLETE! 🎉") 22 | 23 | again = input("\n🔄 Start another countdown? (yes/no): ").lower() 24 | if not again.startswith("y"): 25 | print("Goodbye! 👋") 26 | break 27 | except ValueError: 28 | print("❌ Please enter a number.") 29 | -------------------------------------------------------------------------------- /0-crash-course/3-input-output.py: -------------------------------------------------------------------------------- 1 | # name = input("What is your name? ") 2 | # print("Hello", name) 3 | 4 | # age = int(input("How old are you? ")) 5 | # years_to_100 = 100 - age 6 | # print(f"You will be 100 in {years_to_100} years") 7 | 8 | # num1 = float(input("Enter first number: ")) 9 | # num2 = float(input("Enter second number: ")) 10 | # sum_result = num1 + num2 11 | # print(f"The sum of {num1} and {num2} is {sum_result}") 12 | 13 | 14 | # Working with multiple inputs on one line 15 | # x, y = input("Enter two values seperated by space: ").split() 16 | # print(f"first value: {x}, second value: {y}") 17 | 18 | 19 | user_choice = input("Choose a color (or press Enter for default): ") 20 | if user_choice == "": 21 | user_choice = "blue" 22 | 23 | print(f"Selected color: {user_choice}") 24 | 25 | 26 | # possiblities are endless 27 | length = float(input("Enter length in meters: ")) 28 | print(f"That's {length * 100} centimeters") 29 | -------------------------------------------------------------------------------- /13-color-mixer/app.py: -------------------------------------------------------------------------------- 1 | print("🎨 COLOR MIXER 🎨") 2 | 3 | color_mixes = { 4 | ("red", "blue"): "purple", 5 | ("red", "yellow"): "orange", 6 | ("blue", "yellow"): "green", 7 | ("blue", "green"): "teal", 8 | ("white", "red"): "pink", 9 | ("red", "green"): "brown", 10 | } 11 | 12 | 13 | while True: 14 | color1 = input("\nEnter first color: ").lower().strip() 15 | color2 = input("Enter second color: ").lower().strip() # "red " => "red" 16 | 17 | mix = None 18 | 19 | if (color1, color2) in color_mixes: 20 | mix = color_mixes[(color1, color2)] 21 | elif (color2, color1) in color_mixes: 22 | mix = color_mixes[(color2, color1)] 23 | 24 | if mix: 25 | print(f"When you mix {color1} and {color2}, you get {mix}!") 26 | else: 27 | print("I don't know what those colors make when mixed.") 28 | 29 | if not input("\nMix more colors? (y/n)").lower().startswith("y"): 30 | print("Goodbye! 👋") 31 | break 32 | -------------------------------------------------------------------------------- /0-crash-course/1-variables&data-types.py: -------------------------------------------------------------------------------- 1 | # print("Hello world!") 2 | 3 | 4 | # Strings 5 | name = "Alex" 6 | # Integer (Whole numbers) 7 | age = 25 8 | # Float (decimal number) 9 | height = 9.5 10 | # Boolean 11 | is_student = True 12 | 13 | # print("Hey my name is " + name) 14 | # print("Hey my name is", name) 15 | 16 | # print(name[-1]) 17 | 18 | # Python is a case-sensitive language, so "Hello" and "hello" are different words. 19 | 20 | message = "hello world" 21 | print(message.upper()) 22 | print(message.lower()) 23 | print(message.capitalize()) 24 | print(message.replace("l", "L")) 25 | print("World" in message) 26 | print(len(message)) 27 | 28 | greeting1 = "Hello" 29 | greeting2 = "hello" 30 | 31 | if greeting1 == greeting2: 32 | print("They are the same") 33 | else: 34 | print("They are different") 35 | 36 | # Type conversion 37 | age_str = "30" 38 | age_num = int(age_str) 39 | print(type(age_num)) 40 | print(type(age_str)) 41 | 42 | price_float = 29.99 43 | price_int = int(price_float) 44 | -------------------------------------------------------------------------------- /0-crash-course/7-lists&dicts.py: -------------------------------------------------------------------------------- 1 | # Lists are collections of items that can store different types of data 2 | 3 | numbers = [1, 2, 3, 4, 5] 4 | print(numbers[0]) 5 | numbers[1] = 22 6 | numbers.append(55) 7 | numbers.remove(3) 8 | 9 | print(numbers) 10 | print(len(numbers)) 11 | 12 | # Slicing lists 13 | numbers = [1, 2, 3, 4, 5] 14 | print(numbers[1:4]) # Elements from index 1 to 3 15 | print(numbers[::2]) # Every other element 16 | print(numbers[::-1]) # Reverse the list 17 | print(numbers + [6, 7, 8]) # Concatenate lists 18 | print(numbers * 2) # Repeat the list 19 | 20 | 21 | # Dictionaries are collections that store data as key-value pairs. 22 | student = { 23 | "name": "Emma", 24 | "age": 22, 25 | "courses": ["Math", "Computer Science"] 26 | } 27 | 28 | print(student["name"]) 29 | student["grade"] = "A" 30 | student["age"] += 10 31 | print(student) 32 | print(student.keys()) 33 | print(student.values()) 34 | print(student.items()) 35 | 36 | for key, value in student.items(): 37 | print(f"{key}: {value}") 38 | 39 | 40 | # Sets are unordered collections of unique items. - No duplicates allowed 41 | unique_colors = {"red", "blue", "green", "green"} 42 | print("unique colors:", unique_colors) 43 | 44 | # Tuples are ordered collections that cannot be changed after creation. 45 | coordinates = (10.5, 20.8) 46 | -------------------------------------------------------------------------------- /0-crash-course/9-builtin-modules.py: -------------------------------------------------------------------------------- 1 | import random 2 | import math 3 | import datetime 4 | import os 5 | import sys 6 | import time 7 | 8 | # Get a random number 9 | random_number = random.randint(1, 10) # 1 and 10 is included 10 | print(f"Random number is {random_number}") 11 | 12 | # choose a random element from a list 13 | fruits = ["apple", "orange", "cherry", "banana"] 14 | random_fruit = random.choice(fruits) 15 | print(f"Random fruit is {random_fruit}") 16 | 17 | # shuffle the list 18 | random.shuffle(fruits) 19 | print(f"Shuffled list: {fruits}") 20 | 21 | # Math module 22 | print(f"Square root of 16: {math.sqrt(16)}") 23 | print(f"Pi: {math.pi}") 24 | print(f"Ceiling of 4.3: {math.ceil(4.3)}") 25 | print(f"Floor of 4.8: {math.floor(4.8)}") 26 | print(f"5 raised to power 3: {math.pow(5, 3)}") 27 | 28 | 29 | # Datetime module 30 | current_time = datetime.datetime.now() 31 | print(f"Current date and time: {current_time}") 32 | print(f"Today's date: {datetime.date.today()}") 33 | print(f"Current year: {datetime.date.today().year}") 34 | 35 | # OS module 36 | current_directory = os.getcwd() 37 | print(f"Current directory: {current_directory}") 38 | print(f"List of files: {os.listdir('.')}") 39 | 40 | 41 | # Time module 42 | print("Waiting for 2 seconds...") 43 | time.sleep(2) 44 | print("Done!") 45 | 46 | # Sys module 47 | print(f"Python version: {sys.version}") 48 | print(f"Platform: {sys.platform}") # e.g., 'win32', 'darwin', 'linux' 49 | -------------------------------------------------------------------------------- /0-crash-course/6-functions.py: -------------------------------------------------------------------------------- 1 | # Functions are blocks of code that can be reused, they can take arguments and return values 2 | 3 | # def greet_everyone(): 4 | # print("Hello everyone!") 5 | 6 | 7 | # greet_everyone() 8 | 9 | 10 | # def greet(name): 11 | # print("Hello,", name) 12 | 13 | 14 | # greet("John") 15 | # greet("Jane") 16 | # greet("Kyle") 17 | 18 | # An example: without functions 19 | # user1 = "Emma" 20 | # print("Hello,", user1, "Welcome to our app") 21 | # print("We hope you enjoy using our services.") 22 | # print("Let us know if you need any help.") 23 | 24 | # user2 = "John" 25 | # print("Hello,", user2, "Welcome to our app") 26 | # print("We hope you enjoy using our services.") 27 | # print("Let us know if you need any help.") 28 | 29 | # user3 = "Bob" 30 | # print("Hello,", user3, "Welcome to our app") 31 | # print("We hope you enjoy using our services.") 32 | # print("Let us know if you need any help.") 33 | 34 | 35 | # With functions 36 | def greet_user(name): 37 | print("Hello,", name, "Welcome to our app") 38 | print("We hope you enjoy using our services.") 39 | print("Let us know if you need any help.") 40 | 41 | 42 | greet_user("Emma") 43 | greet_user("John") 44 | greet_user("Bob") 45 | 46 | 47 | def power(base, exponent): 48 | return base ** exponent 49 | 50 | 51 | # x = power(2, 5) # 32 52 | # y = power(8, 2) # 64 53 | # z = power(3, 3) # 27 54 | 55 | print(power(2, 5)) 56 | print(power(8, 2)) 57 | print(power(3, 3)) 58 | -------------------------------------------------------------------------------- /15-guess-the-number/app.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | print("🎮 Welcome to the Number Guessing Game! 🎮") 4 | print("🤔 I'm thinking of a number between 1 and 100. You have 10 attempts. 🔢") 5 | 6 | playing = True 7 | while playing: 8 | secret_number = random.randint(1, 100) 9 | attempts = 0 10 | max_attempts = 10 11 | 12 | game_over = False 13 | 14 | while attempts < max_attempts and not game_over: 15 | try: 16 | guess = int( 17 | input(f"🎯 Attempt {attempts + 1}/{max_attempts}. Enter your guess: ")) 18 | except ValueError: 19 | print("❌ Please enter a valid number") 20 | continue 21 | 22 | attempts += 1 23 | 24 | if guess < secret_number: 25 | print("📉 Too low! Try a higher number! ⬆️") 26 | elif guess > secret_number: 27 | print("📈 Too high! Try a lower number! ⬇️") 28 | else: 29 | print( 30 | f"🎉 Congrats! You guessed the number {secret_number} in {attempts} attempts") 31 | game_over = True 32 | 33 | if attempts < max_attempts and not game_over: 34 | print(f"⏳ You have {max_attempts-attempts} attemps left!") 35 | 36 | if not game_over: 37 | print(f"😭 Game over! The number was {secret_number}") 38 | 39 | play_again = input("🔄 Would you like to play again? (yes/no): ").lower() 40 | 41 | if play_again.startswith("y"): 42 | print("New game starting...\n") 43 | else: 44 | print("Goodbye! 👋") 45 | playing = False 46 | -------------------------------------------------------------------------------- /31-tkinter-calculator/app.py: -------------------------------------------------------------------------------- 1 | import tkinter as tk 2 | 3 | 4 | def calculate_sum(): 5 | try: 6 | num1 = float(first_number.get()) 7 | num2 = float(second_number.get()) 8 | 9 | result = num1 + num2 10 | 11 | result_label.config(text=f"Result: {result}") 12 | except ValueError: 13 | result_label.config(text="Please enter valid numbers!") 14 | 15 | 16 | # create the main window 17 | window = tk.Tk() 18 | window.title("Simple Calculator") 19 | window.geometry("300x250") 20 | 21 | title_label = tk.Label(window, text="Simple Calculator", font=("Arial", 16)) 22 | title_label.pack(pady=10) 23 | 24 | frame1 = tk.Frame(window) 25 | frame1.pack(pady=5) 26 | 27 | num1_label = tk.Label(frame1, text="First Number:") 28 | num1_label.pack(side=tk.LEFT) 29 | 30 | first_number = tk.Entry(frame1, width=10) 31 | first_number.pack() 32 | 33 | 34 | frame2 = tk.Frame(window) 35 | frame2.pack(pady=5) 36 | 37 | num2_label = tk.Label(frame2, text="Second Number:") 38 | num2_label.pack(side=tk.LEFT) 39 | 40 | second_number = tk.Entry(frame2, width=10) 41 | second_number.pack() 42 | 43 | calculate_button = tk.Button(window, text="Add Numbers", command=calculate_sum) 44 | calculate_button.pack(pady=10) 45 | 46 | result_label = tk.Label(window, text="Result: ", font=("Arial", 12)) 47 | result_label.pack(pady=10) 48 | 49 | 50 | def clear_fields(): 51 | first_number.delete(0, tk.END) 52 | second_number.delete(0, tk.END) 53 | result_label.config(text="Result: ") 54 | 55 | 56 | clear_button = tk.Button(window, text="Clear", command=clear_fields) 57 | clear_button.pack(pady=5) 58 | 59 | window.mainloop() 60 | -------------------------------------------------------------------------------- /17-calculator/app.py: -------------------------------------------------------------------------------- 1 | def add(x, y): 2 | return x+y 3 | 4 | 5 | def substract(x, y): 6 | return x - y 7 | 8 | 9 | def multiply(x, y): 10 | return x * y 11 | 12 | 13 | def divide(x, y): 14 | if y == 0: 15 | return "Error! Divison by zero is not allowed." 16 | return x / y 17 | 18 | 19 | def main(): 20 | print("\n==== 🧮 Simple Calculator 🧮 ====") 21 | print("Select operation:") 22 | print("1. ➕ Addition") 23 | print("2. ➖ Subtraction") 24 | print("3. ✖️ Multiplication") 25 | print("4. ➗ Division") 26 | 27 | while True: 28 | choice = input("\nEnter choice (1-4):") 29 | if choice not in ["1", "2", "3", "4"]: 30 | print("Invalid input. Please enter a num between 1 and 4") 31 | else: 32 | break 33 | 34 | try: 35 | num1 = float(input("Enter first number: ")) 36 | num2 = float(input("Enter second number: ")) 37 | except ValueError: 38 | print("❌ Error! Please enter valid numbers!") 39 | return 40 | 41 | if choice == "1": 42 | print(f"\n{num1} + {num2} = {add(num1, num2)}") 43 | elif choice == "2": 44 | print(f"\n{num1} - {num2} = {substract(num1, num2)}") 45 | elif choice == "3": 46 | print(f"\n{num1} x {num2} = {multiply(num1, num2)}") 47 | elif choice == "4": 48 | print(f"\n{num1} / {num2} = {divide(num1, num2)}") 49 | 50 | again = input( 51 | "\nDo you want to perform another calculation? (yes/no): ").lower() 52 | if not again.startswith("y"): 53 | print("Goodbye!") 54 | return 55 | else: 56 | main() 57 | 58 | 59 | main() 60 | -------------------------------------------------------------------------------- /24-currency-converter/app.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | 4 | def main(): 5 | print("\n✨ Simple Currency Converter ✨") 6 | 7 | print("🔄 Getting exchange rates...") 8 | 9 | try: 10 | response = requests.get("https://open.er-api.com/v6/latest/USD") 11 | rates = response.json()["rates"] 12 | print("✅ Got rates successfully!") 13 | except: 14 | print("❌ Error: Couldn't connect to exchange rate API") 15 | return 16 | 17 | print("\n💼 Popular: USD EUR GBP JPY CAD AUD CNY INR") 18 | 19 | while True: 20 | print("\n💸 Enter details:") 21 | from_currency = input("From currency code (e.g. USD): ").upper() 22 | if from_currency not in rates: 23 | print(f"❌ Invalid code: {from_currency}") 24 | continue 25 | 26 | to_currency = input("To currency code (e.g. EUR): ").upper() 27 | if to_currency not in rates: 28 | print(f"❌ Invalid code: {from_currency}") 29 | continue 30 | 31 | try: 32 | amount = float(input(f"Amount in {from_currency}: ")) 33 | except: 34 | print("❌ Please enter a valid number") 35 | continue 36 | 37 | amount_in_usd = amount / rates[from_currency] 38 | result = amount_in_usd * rates[to_currency] 39 | 40 | print( 41 | f"\n💰 Result: {amount} {from_currency} = {result:.2f} {to_currency}") 42 | print( 43 | f"Rate: 1 {from_currency} = {rates[to_currency]/rates[from_currency]:.4f} {to_currency}") 44 | 45 | if not input("\n Convert again? (y/n): ").lower().startswith("y"): 46 | print("👋 Thanks for playing!") 47 | break 48 | 49 | 50 | main() 51 | -------------------------------------------------------------------------------- /0-crash-course/4-conditionals.py: -------------------------------------------------------------------------------- 1 | # Python uses indentation to define blocks of code, not curly brackets or other symbols. 2 | 3 | temp = 28 4 | if temp > 30: 5 | print("It's hot outside") 6 | elif temp > 20: 7 | print("It's a nice day!") 8 | else: 9 | print("It's cold outside") 10 | 11 | 12 | # Checking multiple conditions with logical operators 13 | age = 25 14 | has_licence = True 15 | 16 | if age >= 18 and has_licence: 17 | print("you can drive a car") 18 | elif age >= 18 and not has_licence: 19 | print("you need to get a driver's lincese first") 20 | else: 21 | print("You are too young to drive.") 22 | 23 | 24 | # Nested conditionals 25 | score = 85 26 | 27 | if score >= 60: 28 | print("You passed!") 29 | if score >= 90: 30 | print("You got an A") 31 | elif score >= 80: 32 | print("You got a B!") 33 | elif score >= 70: 34 | print("You got a C!") 35 | else: 36 | print("You got a D!") 37 | else: 38 | print("You failed") 39 | 40 | 41 | # using the "in" operator with conditionals 42 | fruit = "apple" 43 | if fruit in ["banana", "orange"]: 44 | print(f"{fruit} is in the list") 45 | 46 | 47 | # Ternary operator (one-line if-else) 48 | age = 20 49 | status = "adult" if age >= 18 else "minor" 50 | print(f"Status: {status}") 51 | 52 | 53 | # Comparing strings 54 | password = "secret123" 55 | if password == "secret123": 56 | print("Access granted") 57 | else: 58 | print("No access!") 59 | 60 | # Chaining comparisons 61 | x = 15 62 | if 10 < x < 20: 63 | print("x is between 10 and 20") 64 | 65 | 66 | # truthy or falsy 67 | user_input = "" 68 | if user_input: 69 | print("Input provided.") 70 | else: 71 | print("no input provided") 72 | -------------------------------------------------------------------------------- /0-crash-course/2-basic-operations.py: -------------------------------------------------------------------------------- 1 | import math 2 | # basic operations 3 | x = 10 4 | y = 5 5 | 6 | print(x+y) 7 | print(x-y) 8 | print(x*y) 9 | print(x/y) 10 | print(x % y) 11 | print(x**y) 12 | 13 | # x = x + 15 14 | x += 15 15 | print(x) 16 | 17 | # string concatination 18 | first_name = "John" 19 | last_name = "Doe" 20 | full_name = first_name + " " + last_name 21 | print(full_name) 22 | 23 | print("Hey my name is " + first_name + " and my last name is " + last_name) 24 | 25 | # f strings 26 | print(f"Hey my name is {first_name} and my last name is {last_name}") 27 | 28 | # int floor division 29 | a = 17 30 | b = 5 31 | print(a / b) # result 3 (rounds down) normally it is 3.4 32 | print(a // b) # result 3 (rounds down) normally it is 3.4 33 | 34 | # assing multiple values 35 | i, j, k = 1, 2, 3 36 | print(i, j, k) 37 | 38 | # swap values 39 | m = 10 40 | n = 20 41 | m, n = n, m 42 | print(m, n) 43 | 44 | # comparions operators 45 | c = 5 46 | d = 10 47 | 48 | print(c == d) 49 | print(c != d) 50 | print(c > d) 51 | print(c < d) 52 | print(c >= d) 53 | print(c <= d) 54 | 55 | # logical operators 56 | a = True 57 | b = False 58 | 59 | 60 | print(a and b) 61 | print(a or b) 62 | print(not b) 63 | 64 | 65 | # string slicing 66 | text = "Python programming" 67 | print(text[0:7]) 68 | print(text[7:]) 69 | print(text[::-1]) 70 | 71 | # String formatting with .format() 72 | name = "Alice" 73 | age = 25 74 | msg = "My name is {} and I am {} years old".format(name, age) 75 | print(msg) 76 | 77 | # Using placeholders 78 | msg2 = "My name is {0} and I am {1} years. {0} is a nice name".format( 79 | name, age) 80 | print(msg2) 81 | 82 | # math module operations 83 | print(math.pi) 84 | print(math.sqrt(16)) 85 | print(math.floor(4.7)) # 4.0 86 | print(math.ceil(5.3)) # 6.0 87 | print(math.pow(2, 3)) # 8 88 | 89 | pi = 3.141592653589793 90 | print(round(pi, 2)) 91 | -------------------------------------------------------------------------------- /0-crash-course/5-loops.py: -------------------------------------------------------------------------------- 1 | # For loop 2 | print("Counting from 1 to 5:") 3 | for i in range(1, 6): 4 | print(i) 5 | 6 | print("\nReversed counting from 5 to 1:") 7 | for i in range(5, 0, -1): 8 | print(i) 9 | 10 | # While loop 11 | count = 1 12 | print("While loop") 13 | while count <= 5: 14 | print(count) 15 | count += 1 16 | 17 | # Reversed while loop 18 | count = 5 19 | print("\nReversed While loop") 20 | while count >= 1: 21 | print(count) 22 | count -= 1 23 | 24 | 25 | # Looping thru a list 26 | fruits = ["apple", "banana", "cherry"] 27 | print("My fruits:") 28 | for fruit in fruits: 29 | print(fruit) 30 | 31 | # Reversing a list 32 | print("\nMy fruits in reverse:") 33 | for fruit in reversed(fruits): 34 | print(fruit) 35 | 36 | 37 | # Loop with enumerate 38 | print("fruit with indicies:") 39 | for index, fruit in enumerate(fruits): 40 | print(f"{index}:{fruit}") 41 | 42 | 43 | # loop with Dictionaries 44 | person = {"name": "John", "age": 30, "city": "NYC"} 45 | print("\nPerson dict") 46 | for key, value in person.items(): 47 | print(f"{key}:{value}") 48 | 49 | # List comprehension (compact loop for creating lists) 50 | squares = [x**2 for x in range(1, 6)] 51 | print("Squares from 1 to 5", squares) 52 | 53 | 54 | # For loop wit zip() - iterate through multiple lists in parallel 55 | colors = ["red", "yellow", "green"] 56 | 57 | print("\nFruits and their colors:") 58 | for fruit, color in zip(fruits, colors): 59 | print(f"{fruit} is {color}") 60 | 61 | 62 | # Break and continue 63 | print("\n Loop with break") 64 | for i in range(1, 10): 65 | if i > 5: 66 | break 67 | print(i) 68 | 69 | print("\n Loop with continue") 70 | for i in range(1, 10): 71 | if i % 2 == 0: 72 | continue # skip even numbers 73 | print(i) 74 | 75 | 76 | # Infinite loops with break condition 77 | print("\nControlled infinite loop:") 78 | i = 1 79 | while True: 80 | print(i) 81 | i += 1 82 | if i > 5: 83 | break 84 | -------------------------------------------------------------------------------- /18-related-word-game/app.py: -------------------------------------------------------------------------------- 1 | import random 2 | import time 3 | 4 | # word pairs => (prompt: related words) 5 | word_pairs = { 6 | "sky": ["blue", "cloud", "bird", "fly", "sun"], 7 | "water": ["drink", "ocean", "swim", "fish", "boat"], 8 | "food": ["eat", "cook", "tasty", "meal", "restaurant"], 9 | "music": ["song", "dance", "listen", "band", "rhythm"], 10 | "book": ["read", "story", "page", "author", "library"], 11 | "tree": ["leaf", "green", "forest", "wood", "shade"], 12 | "car": ["drive", "road", "wheel", "travel", "speed"], 13 | "dog": ["pet", "bark", "walk", "loyal", "puppy"] 14 | } 15 | 16 | print("\n=== 🔄 WORD ASSOCIATION GAME 🔄 ===") 17 | print("✨ Respond with a related word quickly! ✨") 18 | 19 | score = 0 20 | rounds = 0 21 | 22 | while True: 23 | # Select a random word prompt 24 | prompt = random.choice(list(word_pairs.keys())) 25 | related_words = word_pairs[prompt] 26 | 27 | print(f"\n🔤 Prompt word: {prompt.upper()}") 28 | print("Quick! Type a word related to this prompt!") 29 | 30 | # Time the player's response 31 | start_time = time.time() 32 | # if the user types " hello " it will be converted to "hello" 33 | response = input("> ").lower().strip() 34 | response_time = time.time() - start_time 35 | 36 | print("response time", response_time) # example output: 2.46475887298584 37 | 38 | # Check if response is related 39 | if response in related_words: 40 | points = max(1, 5 - int(response_time)) 41 | score += points 42 | print( 43 | f"✅ Good association! +{points} points (answered in {response_time:.1f}s)") 44 | else: 45 | print( 46 | f"❌ Not a common association. Related words included: {', '.join(related_words)}") 47 | 48 | rounds += 1 49 | print(f"Score: {score}/{rounds * 5} possible points") 50 | 51 | # Ask to play again 52 | if input("\n🔄 Play again? (yes/no): ").lower().startswith('n'): 53 | print(f"Final score: {score}. Thanks for playing! 👋") 54 | break 55 | -------------------------------------------------------------------------------- /19-memory-sequence-game/app.py: -------------------------------------------------------------------------------- 1 | import random 2 | import time 3 | import os 4 | 5 | 6 | def clear_screen(): 7 | """Clear the terminal screen.""" 8 | os.system("cls" if os.name == "nt" else "clear") 9 | 10 | 11 | print("\n=== 🧠 MEMORY SEQUENCE GAME 🧠 ===") 12 | print("✨ Remember the sequence and type it back! ✨") 13 | print("\nRules:") 14 | print("- Watch as numbers appear one by one") 15 | print("- After the sequence is shown, type it back in order") 16 | print("- Each round adds one more number to remember") 17 | print("- How far can you go? 🏆\n") 18 | 19 | input("Press Enter to start...") 20 | 21 | sequence = [] 22 | current_round = 1 23 | game_over = False 24 | 25 | while not game_over: 26 | sequence.append(random.randint(1, 9)) 27 | 28 | clear_screen() 29 | print(f"\n=== Round {current_round} ===") 30 | print(f"Remember this sequence of {len(sequence)} numbers: ") 31 | 32 | for number in sequence: 33 | time.sleep(0.7) 34 | print(f"\n{number}") 35 | time.sleep(0.7) 36 | clear_screen() 37 | 38 | print("\nNow repeat the sequence by typing each number, seperated by spaces:") 39 | player_answer = input("> ") 40 | 41 | # "3,6,1" => ["3","6","1"] => [3,6,1] 42 | 43 | try: 44 | player_sequnece = [int(num) for num in player_answer.split()] 45 | except ValueError: 46 | print("❌ Please enter numbes only!") 47 | game_over = True 48 | continue 49 | 50 | if player_sequnece == sequence: 51 | print(f"🎉 Congrats! You remembred all {len(sequence)} numbers!") 52 | current_round += 1 53 | time.sleep(2) 54 | else: 55 | print(f"😭 Game over! You remembred all {current_round - 1} numbers!") 56 | print( 57 | f"The correct sequence was: {" ".join(str(num) for num in sequence)}") 58 | game_over = True 59 | 60 | if game_over: 61 | play_again = input("\nPlay again? (yes/no): ").lower() 62 | if play_again.startswith("y"): 63 | sequence = [] 64 | current_round = 1 65 | game_over = False 66 | else: 67 | print("Thanks for playing! 👋") 68 | -------------------------------------------------------------------------------- /21-task-manager/app.py: -------------------------------------------------------------------------------- 1 | tasks = [] 2 | 3 | 4 | def display_menu(): 5 | print("\n=== Task Manager ===") 6 | print("1. Add Task") 7 | print("2. View Tasks") 8 | print("3. Complete Task") 9 | print("4. Delete Task") 10 | print("0. Exit") 11 | print("=======================") 12 | 13 | 14 | def add_task(): 15 | title = input("Enter task title: ") 16 | tasks.append({"title": title, "completed": False}) 17 | print(f"Task {title} added successfully!") 18 | 19 | 20 | def view_tasks(): 21 | if not tasks: 22 | print("No tasks found.") 23 | return 24 | 25 | print("\n=== My tasks ===") 26 | for index, task in enumerate(tasks): 27 | status = "✓" if task["completed"] else " " 28 | print(f"{index + 1}. [{status}] {task["title"]}") 29 | 30 | print("================\n") 31 | 32 | 33 | def complete_task(): 34 | view_tasks() 35 | 36 | if not tasks: 37 | return 38 | 39 | try: 40 | task_number = int(input("Enter task number to mark as completed: ")) 41 | if task_number < 1 or task_number > len(tasks): 42 | print("Invalid task number.") 43 | return 44 | 45 | task_to_completed = tasks[task_number - 1] 46 | task_to_completed["completed"] = True 47 | print(f"Task '{task_to_completed["title"]}' marked as completed!") 48 | except ValueError: 49 | print("Please enter a valid number.") 50 | 51 | 52 | def delete_task(): 53 | view_tasks() 54 | 55 | if not tasks: 56 | return 57 | 58 | try: 59 | task_number = int(input("Enter task number to delete: ")) 60 | if task_number < 1 or task_number > len(tasks): 61 | print("Invalid task number.") 62 | return 63 | 64 | deleted_task = tasks.pop(task_number - 1) 65 | print(f"Task '{deleted_task["title"]}' deleted successfully!") 66 | except ValueError: 67 | print("Please enter a valid number.") 68 | 69 | 70 | def main(): 71 | while True: 72 | display_menu() 73 | choice = input("Enter your choice (0-4): ") 74 | 75 | if choice == "1": 76 | add_task() 77 | elif choice == "2": 78 | view_tasks() 79 | elif choice == "3": 80 | complete_task() 81 | elif choice == "4": 82 | delete_task() 83 | elif choice == "0": 84 | print("Goodbye! 👋") 85 | break 86 | else: 87 | print("❌ Invalid choice. Please go with (0-4)") 88 | 89 | 90 | main() 91 | -------------------------------------------------------------------------------- /33-drawing-app/app.py: -------------------------------------------------------------------------------- 1 | import tkinter as tk 2 | from tkinter import colorchooser 3 | 4 | currext_x, current_y = 0, 0 5 | color = "black" 6 | pen_size = 5 7 | 8 | 9 | def start_position(event): 10 | global currext_x, current_y 11 | 12 | currext_x, current_y = event.x, event.y 13 | 14 | 15 | def draw_line(event): 16 | global currext_x, current_y 17 | canvas.create_line(currext_x, current_y, event.x, event.y, 18 | fill=color, width=pen_size, capstyle=tk.ROUND, smooth=True 19 | ) 20 | currext_x, current_y = event.x, event.y 21 | 22 | 23 | def change_color(): 24 | global color 25 | new_color = colorchooser.askcolor()[1] 26 | if new_color: 27 | color = new_color 28 | color_button.config(bg=color) 29 | 30 | 31 | def clear_canvas(): 32 | canvas.delete("all") 33 | 34 | 35 | def change_pen_size(new_size): 36 | global pen_size 37 | pen_size = new_size 38 | 39 | 40 | def set_small_pen(): 41 | change_pen_size(2) 42 | 43 | 44 | def set_medium_pen(): 45 | change_pen_size(5) 46 | 47 | 48 | def set_large_pen(): 49 | change_pen_size(10) 50 | 51 | 52 | window = tk.Tk() 53 | window.title("Simple Drawing App") 54 | window.geometry("800x600") 55 | 56 | title_label = tk.Label(window, text="Simple Drawing App", font=("Arial", 16)) 57 | title_label.pack(pady=10) 58 | 59 | toolbar = tk.Frame(window) 60 | toolbar.pack(fill=tk.X, pady=5) 61 | 62 | color_button = tk.Button(toolbar, text="Choose Color", 63 | command=change_color, bg=color) 64 | color_button.pack(side=tk.LEFT, padx=5) 65 | 66 | clear_button = tk.Button(toolbar, text="Clear Canvas", command=clear_canvas) 67 | clear_button.pack(side=tk.LEFT, padx=5) 68 | 69 | size_frame = tk.Frame(toolbar) 70 | size_frame.pack(side=tk.LEFT, padx=15) 71 | 72 | size_label = tk.Label(size_frame, text="Pen Size:") 73 | size_label.pack(side=tk.LEFT) 74 | 75 | 76 | small_button = tk.Button(size_frame, text="Small", command=set_small_pen) 77 | small_button.pack(side=tk.LEFT, padx=2) 78 | 79 | medium_button = tk.Button(size_frame, text="Medium", command=set_medium_pen) 80 | medium_button.pack(side=tk.LEFT, padx=2) 81 | 82 | large_button = tk.Button(size_frame, text="Large", command=set_large_pen) 83 | large_button.pack(side=tk.LEFT, padx=2) 84 | 85 | canvas = tk.Canvas(window, bg="white") 86 | canvas.pack(fill=tk.BOTH, expand=True, padx=10, pady=10) 87 | 88 | # bind mouse events to the canvas 89 | # this records the starting coordinates for drawing 90 | canvas.bind("", start_position) 91 | canvas.bind("", draw_line) # this tracks movement and draws lines 92 | 93 | instruction_label = tk.Label( 94 | window, text="Click and drag to draw", font=("Arial", 10)) 95 | instruction_label.pack(pady=5) 96 | 97 | 98 | window.mainloop() 99 | -------------------------------------------------------------------------------- /22-simple-chat-bot/app.py: -------------------------------------------------------------------------------- 1 | import random 2 | import time 3 | 4 | 5 | def chatbot(): 6 | greetings = ["Hello there! 👋", "Hi friend! ☺️", 7 | "Hey! Nice to meet you! 🎉", "Howdy! 😃"] 8 | farewells = ["Goodbye! 👋", "See you later! 🚀", 9 | "Bye bye! 😊", "Until next time! ✨"] 10 | jokes = [ 11 | "Why don't scientists trust atoms? Because they make up everything! 🤣", 12 | "What do you call a fake noodle? An impasta! 🍝", 13 | "Why did the scarecrow win an award? Because he was outstanding in his field! 🌾", 14 | "What do you call a bear with no teeth? A gummy bear! 🐻" 15 | ] 16 | facts = [ 17 | "Honey never spoils! Archaeologists found 3000-year-old honey that's still good! 🍯", 18 | "Octopuses have three hearts! 🐙", 19 | "A day on Venus is longer than a year on Venus! ☀️", 20 | "The Hawaiian alphabet has only 12 letters! 🏝️" 21 | ] 22 | 23 | bot_name = "ChatBot" 24 | print(f"🤖 {bot_name} is starting up...") 25 | time.sleep(1) 26 | 27 | print(f""" 28 | 🤖 Welcome to {bot_name}! 🤖 29 | 30 | I can chat about: 31 | 🎯 'joke' - Hear a funny joke 32 | 🧠 'fact' - Learn something new 33 | 🌈 'color' - My favorite color 34 | 👋 'bye' - End our chat 35 | """) 36 | 37 | chatting = True 38 | user_name = input("What's your name: ").lower().strip() 39 | print(f"🤖 {bot_name}: Nice to meet you, {user_name}! How can I help you today?") 40 | 41 | while chatting: 42 | user_input = input("😄 You: ").strip() 43 | 44 | if user_input in ["hi", "hello", "hey", "howdy"]: 45 | print(f"🤖 {bot_name}: {random.choice(greetings)}") 46 | 47 | elif "joke" in user_input: 48 | print(f"🤖 {bot_name}: {random.choice(jokes)}") 49 | 50 | elif "fact" in user_input: 51 | print(f"🤖 {bot_name}: {random.choice(facts)}") 52 | 53 | elif "color" in user_input: 54 | print(f"🤖 {bot_name}: My favorite color is robot blue! 🔵 What's yours?") 55 | color = input("😄 You: ").strip() 56 | print(f"🤖 {bot_name}: {color} is a great color! 🎨") 57 | 58 | elif user_input in ["bye", "goodbye", "exit", "quit"]: 59 | print(f"🤖 {bot_name}: {random.choice(farewells)}") 60 | print(f"🤖 {bot_name}: It was fun chatting with you, {user_name}") 61 | chatting = False 62 | 63 | else: 64 | responses = [ 65 | "That's interesting! Tell me more.", 66 | "I'm not sure I understand. Can you try again?", 67 | "Hmm, let's talk about something else. Try asking for a joke or fact!", 68 | "Beep boop! My robot brain is processing that... 🤔" 69 | ] 70 | print(f"🤖 {bot_name}: {random.choice(responses)}") 71 | 72 | print("Thanks for chatting! Run the program again to talk to me later! 👋") 73 | 74 | 75 | chatbot() 76 | -------------------------------------------------------------------------------- /23-word-counter/app.py: -------------------------------------------------------------------------------- 1 | 2 | def count_words(text): 3 | words = text.split() 4 | return len(words) 5 | 6 | 7 | def count_characters(text, include_spaces): 8 | if include_spaces: 9 | return len(text) 10 | else: 11 | return len(text.replace(" ", "")) 12 | 13 | 14 | def count_sentences(text): 15 | # basic sentence counting: by periods, exclamation marks, and question marks 16 | sentence_endings = [".", "!", "?"] 17 | count = 0 18 | 19 | for char in text: 20 | if char in sentence_endings: 21 | count += 1 22 | 23 | # handling the edge case 24 | if count == 0 and text.strip(): 25 | count = 1 26 | 27 | return count 28 | 29 | 30 | def analyze_text(text): 31 | word_count = count_words(text) 32 | char_count_with_spaces = count_characters(text, True) 33 | char_count_without_spaces = count_characters(text, False) 34 | sentence_count = count_sentences(text) 35 | 36 | if sentence_count > 0: 37 | words_per_sentence = word_count / sentence_count 38 | else: 39 | words_per_sentence = 0 40 | 41 | if word_count > 0: 42 | chars_per_word = char_count_with_spaces / word_count 43 | else: 44 | chars_per_word = 0 45 | 46 | print("\n===== 📊 Text Analysis Results 📊 =====") 47 | print(f"• 📝 Words: {word_count}") 48 | print(f"• 🔤 Characters (with spaces): {char_count_with_spaces}") 49 | print(f"• 🔡 Characters (without spaces): {char_count_without_spaces}") 50 | print(f"• 📃 Sentences: {sentence_count}") 51 | print(f"• 📏 Average words per sentence: {words_per_sentence:.1f}") 52 | print(f"• 📐 Average characters per word: {chars_per_word:.1f}") 53 | 54 | reading_time_minutes = word_count / 225 55 | if reading_time_minutes < 1: 56 | reading_time_seconds = reading_time_minutes * 60 57 | print( 58 | f"• ⏱️ Estimated reading time: {reading_time_seconds:.0f} seconds") 59 | else: 60 | print( 61 | f"• ⏱️ Estimated reading time: {reading_time_minutes:.1f} minutes") 62 | 63 | 64 | def main(): 65 | print("\n==== 📝 Word Counter 📝 ====") 66 | print("Count words, characters, and sentences in your text ✨") 67 | 68 | while True: 69 | print("\nChoose an option: ") 70 | print("1. 📄 Enter text to analyze") 71 | print("2. 🚪 Exit") 72 | 73 | choice = input("\nYour choice (1/2): ") 74 | 75 | if choice == "1": 76 | print("\n Enter or paste your text below (press Enter twice to finish): ") 77 | lines = [] 78 | 79 | while True: 80 | line = input() 81 | if not line and not lines[-1]: 82 | break 83 | 84 | lines.append(line) 85 | 86 | text = "\n".join(lines) 87 | 88 | if not text.strip(): 89 | print("❌ No text provided. Please try again") 90 | continue 91 | 92 | analyze_text(text) 93 | 94 | elif choice == "2": 95 | print("Goodbye 👋") 96 | break 97 | else: 98 | print("❌ Invalid choice. Please enter 1 or 2.") 99 | 100 | 101 | main() 102 | -------------------------------------------------------------------------------- /32-task-manager/app.py: -------------------------------------------------------------------------------- 1 | import tkinter as tk 2 | from tkinter import messagebox 3 | import json 4 | 5 | 6 | def add_task(): 7 | task = task_entry.get() 8 | 9 | if task: 10 | task_listbox.insert(tk.END, task) 11 | task_entry.delete(0, tk.END) 12 | 13 | save_tasks() 14 | else: 15 | messagebox.showwarning("Warning", "Please enter a task!") 16 | 17 | 18 | def delete_task(): 19 | try: 20 | selected_task_index = task_listbox.curselection()[0] 21 | 22 | task_listbox.delete(selected_task_index) 23 | 24 | save_tasks() 25 | except IndexError: 26 | messagebox.showwarning("Warning", "Please select a task to delete!") 27 | 28 | 29 | def mark_completed(): 30 | try: 31 | selected_task_index = task_listbox.curselection()[0] 32 | 33 | task = task_listbox.get(selected_task_index) 34 | 35 | if task.startswith("✓ "): 36 | task = task[2:] 37 | else: 38 | task = "✓ " + task 39 | 40 | task_listbox.delete(selected_task_index) 41 | task_listbox.insert(selected_task_index, task) 42 | 43 | save_tasks() 44 | 45 | except IndexError: 46 | messagebox.showwarning( 47 | "Warning", "Please select a task to mark as completed!") 48 | 49 | 50 | def save_tasks(): 51 | tasks = task_listbox.get(0, tk.END) 52 | 53 | with open("tasks.json", "w") as file: 54 | json.dump(list(tasks), file) 55 | 56 | 57 | def load_tasks(): 58 | try: 59 | with open("tasks.json", "r") as file: 60 | tasks = json.load(file) 61 | 62 | for task in tasks: 63 | task_listbox.insert(tk.END, task) 64 | 65 | except FileNotFoundError: 66 | pass 67 | 68 | 69 | window = tk.Tk() 70 | window.title("Task Manager App") 71 | window.geometry("400x450") 72 | window.resizable(False, False) 73 | 74 | title_label = tk.Label(window, text="To-Do List", font=("Arial", 18, "bold")) 75 | title_label.pack(pady=10) 76 | 77 | input_frame = tk.Frame(window) 78 | input_frame.pack(pady=10) 79 | 80 | task_entry = tk.Entry(input_frame, width=30, font=("Arial", 12)) 81 | task_entry.pack(side=tk.LEFT, padx=5) 82 | 83 | add_button = tk.Button(input_frame, text="Add Task", command=add_task) 84 | add_button.pack(side=tk.LEFT) 85 | 86 | list_frame = tk.Frame(window) 87 | list_frame.pack(pady=10, fill=tk.BOTH, expand=True) 88 | 89 | scrollbar = tk.Scrollbar(list_frame) 90 | scrollbar.pack(side=tk.RIGHT, fill=tk.Y) 91 | 92 | task_listbox = tk.Listbox(list_frame, width=45, height=12, font=("Arial", 12), 93 | selectmode=tk.SINGLE, yscrollcommand=scrollbar.set 94 | ) 95 | task_listbox.pack(side=tk.LEFT, fill=tk.BOTH, expand=True) 96 | 97 | scrollbar.config(command=task_listbox.yview) 98 | 99 | button_frame = tk.Frame(window) 100 | button_frame.pack(pady=10) 101 | 102 | complete_button = tk.Button( 103 | button_frame, text="Mark as Completed", command=mark_completed) 104 | complete_button.pack(side=tk.LEFT, padx=5) 105 | 106 | delete_button = tk.Button( 107 | button_frame, text="Delete Task", command=delete_task) 108 | delete_button.pack(side=tk.LEFT, padx=5) 109 | 110 | load_tasks() 111 | 112 | window.mainloop() 113 | -------------------------------------------------------------------------------- /26-personal-finance-tracker/app.py: -------------------------------------------------------------------------------- 1 | import os 2 | import datetime 3 | 4 | 5 | DATA_FILE = "my_finances.txt" 6 | 7 | 8 | def add_transaction(): 9 | print("\n💰 ADD TRANSACTION 💰") 10 | 11 | while True: 12 | transaction_type = input("➕ Income or ➖ Expense? (i/e): ").lower() 13 | if transaction_type in ["i", "e"]: 14 | break 15 | print("❌ Please enter 'i' or 'e' ") 16 | 17 | amount = input("💵 Enter amount: $") 18 | category = input("🏷️ Enter category: ") 19 | description = input("📝 Enter description: ") 20 | today = datetime.datetime.now().strftime("%Y-%m-%d") 21 | symbol = "+" if transaction_type == "i" else "-" 22 | 23 | # This opens the file in "append mode" ('a').The "append mode" means new data will be added to the end of the file without deleting existing content 24 | # The with statement is a clean way to handle files that automatically closes them when you're done 25 | 26 | with open(DATA_FILE, "a") as file: 27 | file.write(f"{today}|{symbol}{amount}|{category}|{description}\n") 28 | 29 | print("✅ Transaction added successfully!") 30 | 31 | 32 | def view_transactions(): 33 | if not os.path.exists(DATA_FILE): 34 | print("No transactions found.") 35 | return 36 | 37 | print("\n📋 TRANSACTIONS 📋") 38 | print("-" * 60) 39 | 40 | print("DATE AMOUNT CATEGORY DESCRIPTION") 41 | print("-" * 60) 42 | 43 | with open(DATA_FILE, "r") as file: 44 | for line in file: 45 | parts = line.strip().split("|") 46 | date = parts[0] 47 | amount = parts[1] 48 | category = parts[2] 49 | description = parts[3] 50 | emoji = "💰" if amount.startswith('+') else "💸" 51 | 52 | print(f"{date} {emoji} {amount} {category} {description}") 53 | 54 | 55 | def get_summary(): 56 | if not os.path.exists(DATA_FILE): 57 | print("\n📭 No transactions found") 58 | return 59 | 60 | total_income = 0 61 | total_expense = 0 62 | 63 | with open(DATA_FILE, "r") as file: 64 | for line in file: 65 | parts = line.strip().split("|") 66 | amount = parts[1] 67 | 68 | if amount.startswith("+"): 69 | total_income += float(amount[1:]) 70 | else: 71 | total_expense += float(amount[1:]) 72 | 73 | balance = total_income - total_expense 74 | 75 | print("\n📊 FINANCIAL SUMMARY 📊") 76 | print(f"💰 Total Income: ${total_income:.2f}") 77 | print(f"💸 Total Expense: ${total_expense:.2f}") 78 | print(f"💵 Balance: ${balance:.2f}") 79 | 80 | 81 | def main(): 82 | while True: 83 | print("\n" + "=" * 30) 84 | print("💰 FINANCE TRACKER 💰") 85 | print("="*30) 86 | print("1. 📝 Add Transaction") 87 | print("2. 📋 View Transactions") 88 | print("3. 📊 Summary") 89 | print("4. 🚪 Exit") 90 | 91 | choice = input("\n🔤 Choice (1-4): ") 92 | 93 | if choice == "1": 94 | add_transaction() 95 | elif choice == "2": 96 | view_transactions() 97 | elif choice == "3": 98 | get_summary() 99 | elif choice == "4": 100 | print("Goodbye! 👋") 101 | break 102 | else: 103 | print("❌ Invalid choice. Please go with (1-4)") 104 | 105 | 106 | main() 107 | -------------------------------------------------------------------------------- /20-rock-paper-scissors/app.py: -------------------------------------------------------------------------------- 1 | import random 2 | import time 3 | 4 | 5 | def display_welcome(): 6 | print("\n==== ROCK PAPER SCISSORS ====") 7 | print("🪨 📄 ✂️") 8 | print("\nRules:") 9 | print("- Rock crushes Scissors") 10 | print("- Scissors cuts Paper") 11 | print("- Paper covers Rock") 12 | print("- First to win 3 rounds is the champion!") 13 | print("\n----------------------------") 14 | 15 | 16 | def get_user_choice(): 17 | while True: 18 | print("\nMake your choice:") 19 | print("1. Rock 🪨") 20 | print("2. Paper 📄") 21 | print("3. Scissors ✂️") 22 | 23 | try: 24 | choice = int(input("Enter your choice (1-3): ")) 25 | if 1 <= choice <= 3: 26 | return choice 27 | else: 28 | print("Please enter a numbe between 1 and 3") 29 | except ValueError: 30 | print("Please enter a valid number.") 31 | 32 | 33 | def get_computer_choice(): 34 | return random.randint(1, 3) 35 | 36 | 37 | def convert_choice_to_text(choice): 38 | options = {1: "Rock 🪨", 2: "Paper 📄", 3: "Scissors ✂️"} 39 | return options[choice] 40 | 41 | 42 | def determine_winner(user_choice, computer_choice): 43 | # tie 44 | if user_choice == computer_choice: 45 | return "tie" 46 | # user wins cases: 47 | elif ((user_choice == 1 and computer_choice == 3) or 48 | (user_choice == 3 and computer_choice == 2) or 49 | (user_choice == 2 and computer_choice == 1)): 50 | return "user" 51 | else: 52 | return "computer" 53 | 54 | 55 | def display_round_result(user_choice, computer_choice, result): 56 | user_text = convert_choice_to_text(user_choice) 57 | computer_text = convert_choice_to_text(computer_choice) 58 | 59 | print(f"\nYou chose: {user_text}") 60 | print("Computer is chosing", end="") 61 | for _ in range(3): 62 | print(".", end="", flush=True) 63 | time.sleep(0.5) 64 | 65 | print(f"Computer chose: {computer_text}") 66 | 67 | if result == "tie": 68 | print("It's a tie! 🤝") 69 | elif result == "user": 70 | print("You win this rounds! 🎉") 71 | else: 72 | print("Computer wins this round! 💻") 73 | 74 | 75 | def play_game(): 76 | """Main game function.""" 77 | display_welcome() 78 | 79 | user_score = 0 80 | computer_score = 0 81 | target_score = 3 82 | round_num = 1 83 | 84 | while user_score < target_score and computer_score < target_score: 85 | print(f"\n===Round {round_num} ===") 86 | print(f"Score: You {user_score} - {computer_score} Computer") 87 | 88 | user_choice = get_user_choice() 89 | computer_choice = get_computer_choice() 90 | 91 | result = determine_winner(user_choice, computer_choice) 92 | display_round_result(user_choice, computer_choice, result) 93 | 94 | if result == "user": 95 | user_score += 1 96 | elif result == "computer": 97 | computer_score += 1 98 | 99 | round_num += 1 100 | 101 | print("\n==== GAME OVER ====") 102 | print(f"Final Score: You {user_score} - {computer_score} Computer") 103 | 104 | if user_score > computer_score: 105 | print("Congrats! You are the champion 🎉") 106 | else: 107 | print("Better luck next time! The computer winds this game.") 108 | 109 | play_again = input("\nDo you want to play again? (y/n): ").lower() 110 | if play_again.startswith("y"): 111 | play_game() 112 | else: 113 | print("Goodbye 👋") 114 | 115 | 116 | play_game() 117 | -------------------------------------------------------------------------------- /28-pomodoro-timer/app.py: -------------------------------------------------------------------------------- 1 | import time 2 | import os 3 | import platform 4 | 5 | 6 | def clear_screen(): 7 | if platform.system() == "Windows": 8 | os.system("cls") 9 | else: 10 | os.system("clear") 11 | 12 | 13 | def format_time(seconds): 14 | # format(30) => 00:30 15 | # format(75) => 01:15 16 | # format(0) => 00:00 17 | 18 | minutes = seconds // 60 19 | seconds_remainder = seconds % 60 20 | return f"{minutes:02d}:{seconds_remainder:02d}" 21 | 22 | 23 | def countdown(seconds, label): 24 | for remaining in range(seconds, 0, -1): 25 | clear_screen() 26 | print(f"\n⏰ {label} ⏰ ") 27 | print(f"\n⏳ Time remaining: {format_time(remaining)}") 28 | 29 | if label == "Work Session": 30 | print("\n🧠 Focus on your task! 💪") 31 | elif "Break" in label: 32 | print("\n☕ Take a breath... 😉") 33 | 34 | time.sleep(1) 35 | 36 | clear_screen() 37 | print(f"\n✅ {label} completed") 38 | 39 | if platform.system() == "Windows": 40 | import winsound 41 | # hertz, duration 42 | winsound.Beep(1000, 500) 43 | else: 44 | print("🔔") 45 | 46 | 47 | def pomodoro_timer(): 48 | try: 49 | clear_screen() 50 | print("\n==== 🍅 Pomodoro Timer 🍅 ====") 51 | 52 | # default settings 53 | work_minutes = 25 54 | short_break_minutes = 5 55 | long_break_minutes = 15 56 | cycles = 4 57 | 58 | customize = input( 59 | "\nUse default settings (25min work, 5min short break, 15min long break?) (yes/no):").lower() 60 | 61 | if customize.startswith("n"): 62 | try: 63 | work_minutes = int( 64 | input("\nEnter work session length (minutes): ")) 65 | short_break_minutes = int( 66 | input("Enter short break length (minutes): ")) 67 | long_break_minutes = int( 68 | input("Enter long break length (minutes): ")) 69 | cycles = int( 70 | input("Enter number of cycles befre a long break: ")) 71 | except ValueError: 72 | print("\n❌Invalid input! Using default settings") 73 | time.sleep(2) 74 | 75 | clear_screen() 76 | print(f"\n🚀 Starting Pomodoro Timer with:") 77 | print(f"• {work_minutes} minute work sessions") 78 | print(f"• {short_break_minutes} minute short breaks") 79 | print(f"• {long_break_minutes} minute long break after {cycles} cycles") 80 | print(f"• Press Ctrl+C at any time to exit") 81 | input("\nPress Enter to begin...") 82 | 83 | # conver minutes to seconds 84 | work_seconds = work_minutes * 60 85 | short_break_seconds = short_break_minutes * 60 86 | long_break_seconds = long_break_minutes * 60 87 | 88 | completed_cycles = 0 89 | 90 | while True: 91 | countdown(work_seconds, "Work Session") 92 | completed_cycles += 1 93 | 94 | if completed_cycles % cycles == 0: 95 | input("\nTime for a long break! Press Enter to start your break...") 96 | countdown(long_break_seconds, "Long Break") 97 | input( 98 | "\nLong break complete! Press Enter to start the next work session...") 99 | else: 100 | input("\nTime for a short break! Press Enter to start your break...") 101 | countdown(short_break_seconds, "Short Break") 102 | input( 103 | "\nShort break complete! Press Enter to start the next work session...") 104 | except KeyboardInterrupt: 105 | clear_screen() 106 | print("Goodbye! 👋") 107 | 108 | 109 | pomodoro_timer() 110 | -------------------------------------------------------------------------------- /25-password-generator/app.py: -------------------------------------------------------------------------------- 1 | import random 2 | import string 3 | 4 | 5 | def generate_password(length, use_lowercase, use_uppercase, use_numbers, use_special): 6 | chars = "" 7 | 8 | if use_lowercase: 9 | chars += string.ascii_lowercase 10 | # chars = "abcdefghijklmnopqrstuvwxyz" 11 | if use_uppercase: 12 | chars += string.ascii_uppercase 13 | # chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 14 | if use_numbers: 15 | chars += string.digits 16 | # chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_#." 17 | if use_special: 18 | chars += string.punctuation 19 | 20 | if not chars: 21 | print("⚠️ Opps! No character types selected. Using lowercase letters by default!") 22 | chars = string.ascii_lowercase 23 | 24 | password = "" 25 | for _ in range(length): 26 | password += random.choice(chars) 27 | 28 | return password 29 | 30 | 31 | def check_password_strength(password): 32 | score = min(len(password) / 16, 1.0) 33 | 34 | has_lower = any(c.islower() for c in password) 35 | has_upper = any(c.isupper() for c in password) 36 | has_digit = any(c.isdigit() for c in password) 37 | has_special = any(c in string.punctuation for c in password) 38 | 39 | variety = (has_lower + has_upper + has_digit + has_special) / 4.0 40 | 41 | final_score = (score * 0.6) + (variety * 0.4) 42 | 43 | if final_score >= 0.8: 44 | return "🔥 ULTRA STRONG 🔥" 45 | elif final_score >= 0.6: 46 | return "💪 STRONG 💪" 47 | elif final_score >= 0.4: 48 | return "👍 DECENT 👍" 49 | else: 50 | return "😬 NEEDS IMPROVEMENT 😬" 51 | 52 | 53 | def get_yes_no_input(question): 54 | while True: 55 | response = input(question + "(y/n): ").lower() 56 | if response in ["yes", "y"]: 57 | return True 58 | elif response in ["no", "n"]: 59 | return False 60 | else: 61 | print("I didn't get that! Please enter 'y' or 'n'.") 62 | 63 | 64 | def main(): 65 | print("\n ==== 🔐 PASSWORD GENERATOR 🔐 ====") 66 | print("✨ Create super strong and secure passwords with ease! ✨") 67 | 68 | while True: 69 | try: 70 | length = int(input("\nEnter password length (8-30): ")) 71 | if 8 <= length <= 30: 72 | break 73 | else: 74 | print("⚠️ Please choose a length between 8 and 30!") 75 | except ValueError: 76 | print("❌ Oops! Please enter a number, like 12 or 16.") 77 | 78 | print("\n Let's customize your password!") 79 | 80 | use_lowercase = get_yes_no_input("Include lowercase letters (a-z)? ") 81 | use_uppercase = get_yes_no_input("Include uppercase letters (A-Z)? ") 82 | use_numbers = get_yes_no_input("Include numbers letters (0-9)? ") 83 | use_special = get_yes_no_input("Include special character (!@$#%)? ") 84 | 85 | print("\n 🧚 Generating your magical password...🧚") 86 | password = generate_password( 87 | length, use_lowercase, use_uppercase, use_numbers, use_special) 88 | 89 | print("\n==== YOUR NEW PASSWORD 🎉") 90 | print(f"🔑 {password}") 91 | 92 | strength = check_password_strength(password) 93 | print(f"💪 Strength: {strength}") 94 | 95 | print("\n📝===== PASSWORD TIPS =====📝") 96 | print("🚫 Never use the same password for multiple accounts") 97 | print("🗄️ Consider using a password manager") 98 | print("🔄 Change important passwords every few months") 99 | print("🛡️ Even strong passwords need to be kept secret!") 100 | 101 | if get_yes_no_input("\nWould you like to create another awesome password? "): 102 | main() 103 | else: 104 | print("\n🎉 Thank you for using the Super Fun Password Generator! Stay secure! 🛡️") 105 | 106 | 107 | main() 108 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🐍 35 Python Projects Collection 🚀 2 | 3 |

4 | Python Logo 5 |

6 | 7 |

A collection of 35 fun Python projects for beginners!

8 |

Based on the YouTube Crash Course by burakorkmez

9 | 10 | ## 📚 About 11 | 12 | This repository contains 35 Python projects designed to help beginners learn programming concepts through hands-on practice. Each project focuses on different aspects of Python and increases in complexity, providing a comprehensive learning path from absolute beginner to confident programmer. 13 | 14 | Perfect for: 15 | 16 | - 🔰 Complete beginners to programming 17 | - 🧠 Those wanting to strengthen their Python fundamentals 18 | - 🎓 Students looking for fun coding projects 19 | - 👨‍💻 Self-taught developers seeking structured practice 20 | 21 | ## 🔥 Projects List 22 | 23 | | # | Project Name | Description | Status | 24 | | --- | -------------------------------------------------------- | ----------------------------- | ------ | 25 | | 00 | [Crash Course](/0-crash-course) | Introduction to Python basics | ✅ | 26 | | 01 | [Website Checker](/01-website-checker) | Check if websites are online | ✅ | 27 | | 02 | [Step Counter](/02-step-counter) | Track and analyze daily steps | ✅ | 28 | | 03 | [Text Formatter](/03-text-formatter) | Format and manipulate text | ✅ | 29 | | 04 | [Character Type Checker](/04-check-char-type) | Check types of characters | ✅ | 30 | | 05 | [Grade Calculator](/05-grade-calculator) | Calculate academic grades | ✅ | 31 | | 06 | [Word Scrambler](/06-word-scrambler) | Scramble and unscramble words | ✅ | 32 | | 07 | [Music Recommender](/07-music-recommender) | Get music recommendations | ✅ | 33 | | 08 | [Random Name Generator](/08-random-name-generator) | Generate random names | ✅ | 34 | | 09 | [Reverse Name](/09-reverse-name) | Reverse strings and names | ✅ | 35 | | 10 | [Vowel Counter](/10-vowel-counter) | Count vowels in text | ✅ | 36 | | 11 | [Coin Flip Game](/11-coin-flip-game) | Simple heads or tails game | ✅ | 37 | | 12 | [Recipe Generator](/12-recipe-generator) | Generate random recipes | ✅ | 38 | | 13 | [Color Mixer](/13-color-mixer) | Mix and create colors | ✅ | 39 | | 14 | [Guess The Word](/14-guess-the-word) | Word guessing game | ✅ | 40 | | 15 | [Guess The Number](/15-guess-the-number) | Number guessing game | ✅ | 41 | | 16 | [Countdown Timer](/16-countdown-timer) | Simple countdown timer | ✅ | 42 | | 17 | [Calculator](/17-calculator) | Basic arithmetic calculator | ✅ | 43 | | 18 | [Related Word Game](/18-related-word-game) | Word association game | ✅ | 44 | | 19 | [Memory Sequence Game](/19-memory-sequence-game) | Test your memory skills | ✅ | 45 | | 20 | [Rock Paper Scissors](/20-rock-paper-scissors) | Classic game implementation | ✅ | 46 | | 21 | [Task Manager](/21-task-manager) | Manage your daily tasks | ✅ | 47 | | 22 | [Simple Chat Bot](/22-simple-chat-bot) | Basic conversational bot | ✅ | 48 | | 23 | [Word Counter](/23-word-counter) | Count words in text | ✅ | 49 | | 24 | [Currency Converter](/24-currency-converter) | Convert between currencies | ✅ | 50 | | 25 | [Password Generator](/25-password-generator) | Generate secure passwords | ✅ | 51 | | 26 | [Personal Finance Tracker](/26-personal-finance-tracker) | Track income and expenses | ✅ | 52 | | 27 | [Quiz Game](/27-quiz-game) | Test your knowledge | ✅ | 53 | | 28 | [Pomodoro Timer](/28-pomodoro-timer) | Productivity timer | ✅ | 54 | | 29 | [Adventure Game](/29-adventure-game) | Text-based adventure | ✅ | 55 | | 30 | [Tkinter Hello World](/30-tkinter-hello-world) | Basic GUI with Tkinter | ✅ | 56 | | 31 | [Tkinter Calculator](/31-tkinter-calculator) | GUI calculator app | ✅ | 57 | | 32 | [Task Manager GUI](/32-task-manager) | Task manager with GUI | ✅ | 58 | | 33 | [Drawing App](/33-drawing-app) | Simple drawing application | ✅ | 59 | 60 | ## 📚 Bonus 2 Projects 61 | 62 | | # | Project Name | Description | Status | 63 | | --- | -------------------------------------------------------------------------- | --------------------------------- | ------ | 64 | | 34 | [Python Chat App](https://github.com/burakorkmez/python-chat) | Python Realtime Chat Applications | ✅ | 65 | | 35 | [Full Stack Web App](https://github.com/burakorkmez/react-python-tutorial) | Python & React Tutorial | ✅ | 66 | 67 | ## 🚀 Happy Coding! 68 | -------------------------------------------------------------------------------- /27-quiz-game/app.py: -------------------------------------------------------------------------------- 1 | import random 2 | import time 3 | 4 | 5 | def display_welcome(): 6 | print("\n" + "=" * 50) 7 | print("🎮 WELCOME TO THE ULTIMATE QUIZ CHALLENGE! 🎮".center(50)) 8 | print("=" * 50) 9 | print("\n📜 Instructions:") 10 | print("- Choose a quiz category") 11 | print("- Answer multiple-choice questions") 12 | print("- Each correct answer is worth 10 points") 13 | print("- See your final score at the end") 14 | print("- Have fun and learn something new!") 15 | 16 | 17 | def display_categories(): 18 | print("\n🗂️ Quiz Categories:") 19 | print("1. 🌎 General Knowledge") 20 | print("2. 🎬 Movies and TV Shows") 21 | print("3. 🔬 Science and Nature") 22 | print("4. 🎮 Video Games") 23 | print("5. 🎲 Random Mix (questions from all categories)") 24 | 25 | 26 | def get_user_choice(): 27 | while True: 28 | try: 29 | choice = int(input("\nSelect a category (1-5): ")) 30 | if 1 <= choice <= 5: 31 | return choice 32 | else: 33 | print(f"❌ Please enter a number between 1 and 5") 34 | except ValueError: 35 | print("❌ Please enter a valid number") 36 | 37 | 38 | def load_questions(): 39 | general_knowledge = [ 40 | { 41 | "question": "What is the capital of France?", 42 | "options": ["A. London", "B. Berlin", "C. Paris", "D. Madrid"], 43 | "answer": "C" 44 | }, 45 | { 46 | "question": "Which planet is known as the Red Planet?", 47 | "options": ["A. Venus", "B. Mars", "C. Jupiter", "D. Saturn"], 48 | "answer": "B" 49 | }, 50 | { 51 | "question": "How many sides does a hexagon have?", 52 | "options": ["A. 5", "B. 6", "C. 7", "D. 8"], 53 | "answer": "B" 54 | }, 55 | { 56 | "question": "What is the largest ocean on Earth?", 57 | "options": ["A. Atlantic Ocean", "B. Indian Ocean", "C. Arctic Ocean", "D. Pacific Ocean"], 58 | "answer": "D" 59 | }, 60 | { 61 | "question": "Which of these is not a primary color?", 62 | "options": ["A. Red", "B. Blue", "C. Green", "D. Yellow"], 63 | "answer": "C" 64 | } 65 | ] 66 | 67 | movies_tv = [ 68 | { 69 | "question": "Who played Iron Man in the Marvel Cinematic Universe?", 70 | "options": ["A. Chris Evans", "B. Robert Downey Jr.", "C. Chris Hemsworth", "D. Mark Ruffalo"], 71 | "answer": "B" 72 | }, 73 | { 74 | "question": "Which TV show features a high school chemistry teacher who becomes a drug dealer?", 75 | "options": ["A. Breaking Bad", "B. The Walking Dead", "C. Game of Thrones", "D. Stranger Things"], 76 | "answer": "A" 77 | }, 78 | { 79 | "question": "What was the first film in the Star Wars original trilogy?", 80 | "options": ["A. The Empire Strikes Back", "B. Return of the Jedi", "C. A New Hope", "D. The Phantom Menace"], 81 | "answer": "C" 82 | }, 83 | { 84 | "question": "Which actress played Katniss Everdeen in The Hunger Games?", 85 | "options": ["A. Emma Watson", "B. Jennifer Lawrence", "C. Scarlett Johansson", "D. Emma Stone"], 86 | "answer": "B" 87 | }, 88 | { 89 | "question": "Which animated movie features a snowman named Olaf?", 90 | "options": ["A. Toy Story", "B. Shrek", "C. Frozen", "D. Finding Nemo"], 91 | "answer": "C" 92 | } 93 | ] 94 | 95 | science_nature = [ 96 | { 97 | "question": "What is the chemical symbol for gold?", 98 | "options": ["A. Go", "B. Au", "C. Ag", "D. Gd"], 99 | "answer": "B" 100 | }, 101 | { 102 | "question": "Which animal can change its color to match its surroundings?", 103 | "options": ["A. Chameleon", "B. Elephant", "C. Giraffe", "D. Penguin"], 104 | "answer": "A" 105 | }, 106 | { 107 | "question": "How many elements are in the periodic table?", 108 | "options": ["A. 92", "B. 100", "C. 118", "D. 120"], 109 | "answer": "C" 110 | }, 111 | { 112 | "question": "What is the largest organ in the human body?", 113 | "options": ["A. Brain", "B. Liver", "C. Heart", "D. Skin"], 114 | "answer": "D" 115 | }, 116 | { 117 | "question": "Which of these is not a type of cloud?", 118 | "options": ["A. Cumulus", "B. Stratus", "C. Cirrus", "D. Nucleus"], 119 | "answer": "D" 120 | } 121 | ] 122 | 123 | video_games = [ 124 | { 125 | "question": "Which video game features a character named Mario?", 126 | "options": ["A. Call of Duty", "B. Super Mario Bros", "C. Minecraft", "D. Fortnite"], 127 | "answer": "B" 128 | }, 129 | { 130 | "question": "What color is the ghost Inky in Pac-Man?", 131 | "options": ["A. Red", "B. Pink", "C. Blue", "D. Orange"], 132 | "answer": "C" 133 | }, 134 | { 135 | "question": "Which game features a character named Master Chief?", 136 | "options": ["A. Halo", "B. God of War", "C. The Last of Us", "D. Uncharted"], 137 | "answer": "A" 138 | }, 139 | { 140 | "question": "In Minecraft, what material is needed to create a torch?", 141 | "options": ["A. Wood and Iron", "B. Coal and Stick", "C. Stone and Flint", "D. Gold and Wood"], 142 | "answer": "B" 143 | }, 144 | { 145 | "question": "Which of these is not a Pokémon type?", 146 | "options": ["A. Fire", "B. Water", "C. Earth", "D. Electric"], 147 | "answer": "C" 148 | } 149 | ] 150 | 151 | return { 152 | 1: {"name": "Generalde Knowledge", "questions": general_knowledge}, 153 | 2: {"name": "Movies and TV Shows", "questions": movies_tv}, 154 | 3: {"name": "Science and Nature", "questions": science_nature}, 155 | 4: {"name": "Video Games", "questions": video_games}, 156 | 5: {"name": "Random Mix", "questions": general_knowledge + movies_tv+science_nature + video_games}, 157 | } 158 | 159 | 160 | def run_quiz(category_data): 161 | category_name = category_data["name"] 162 | questions = category_data["questions"] 163 | 164 | random.shuffle(questions) 165 | 166 | print(f"\n🎯 Starting the {category_name} quiz! 🎯") 167 | print("Answer each question by typing the letter of your choice (A,B,C, or D).") 168 | 169 | score = 0 170 | correct_answers = 0 171 | 172 | for i, q in enumerate(questions): 173 | print(f"\n-------- Question {i+1}/{len(questions)} ---------") 174 | print(f"? {q["question"]}") 175 | 176 | for option in q["options"]: 177 | print(option) 178 | 179 | while True: 180 | user_answer = input("\nYour answer (A/B/C/D): ").upper() 181 | if user_answer not in ["A", "B", "C", "D"]: 182 | print("❌ Please enter A,B,C, or D.") 183 | else: 184 | break 185 | 186 | correct = user_answer == q["answer"] 187 | 188 | if correct: 189 | score += 10 190 | correct_answers += 1 191 | print("✅ Correct! +10 points") 192 | else: 193 | print(f"❌ Wrong! The correct answer is {q["answer"]}") 194 | 195 | if i < len(questions) - 1: 196 | print("\nNext question coming up...") 197 | time.sleep(1.5) 198 | 199 | print("\n" + "="*50) 200 | print("📊 QUIZ RESULTS 📊".center(50)) 201 | print("="*50) 202 | print(f"Category: {category_name}") 203 | print(f"Correct Answers: {correct_answers}/{len(questions)}") 204 | print(f"Total Score: {score} points") 205 | 206 | percentage = (score / (len(questions)*10)) * 100 207 | 208 | if percentage == 100: 209 | print("\n🏆 PERFECT SCORE! You're a quiz master! 🏆") 210 | elif percentage >= 80: 211 | print("\n🌟 EXCELLENT! You really know your stuff!") 212 | elif percentage >= 60: 213 | print("\n😊 GOOD JOB! You've got decent knowledge!") 214 | elif percentage >= 40: 215 | print("\n🤔 NOT BAD! There's room for improvement.") 216 | else: 217 | print("\n📚 KEEP LEARNING! Practice makes perfect!") 218 | 219 | return score 220 | 221 | 222 | def main(): 223 | display_welcome() 224 | 225 | total_score = 0 226 | play_again = True 227 | 228 | while play_again: 229 | display_categories() 230 | 231 | category_choice = get_user_choice() # 1 232 | 233 | all_categories = load_questions() 234 | score = run_quiz(all_categories[category_choice]) 235 | 236 | total_score += score 237 | 238 | again = input("\nPlay another round? (yes/no): ").lower() # hello 239 | 240 | while not (again.startswith("y") or again.startswith("n")): 241 | print("Please type yes or no.") 242 | again = input("Play another round? (yes/no): ").lower() 243 | 244 | play_again = again.startswith("y") 245 | 246 | print( 247 | f"\n🎉 Thanks for playing! Your total score from all rounds: {total_score} points 🎉") 248 | 249 | 250 | main() 251 | -------------------------------------------------------------------------------- /29-adventure-game/app.py: -------------------------------------------------------------------------------- 1 | import time 2 | import random 3 | 4 | # Player Stats 5 | player = { 6 | "name": "", 7 | "health": 100, 8 | "gold": 50, 9 | "items": [] 10 | } 11 | 12 | # Game locations 13 | locations = { 14 | "town": { 15 | "description": "A bustling town with shops and friendly people.", 16 | "options": ["shop", "forest", "rest"] 17 | }, 18 | "forest": { 19 | "description": "A dark forest with strange sounds and hidden treasures.", 20 | "options": ["explore", "return to town", "camp"] 21 | }, 22 | "shop": { 23 | "description": "A small shop with various items for sale.", 24 | "options": ["buy health potion (20 gold)", "buy sword (50 gold)", "return to town"] 25 | } 26 | } 27 | 28 | # Items with effects 29 | items = { 30 | "health potion": {"health": 30, "price": 20}, 31 | "sword": {"damage": 10, "price": 50} 32 | } 33 | 34 | # Enemies that can be encountered 35 | enemies = [ 36 | {"name": "Goblin", "health": 30, "damage": 5, "gold": 15}, 37 | {"name": "Wolf", "health": 20, "damage": 7, "gold": 10}, 38 | {"name": "Bandit", "health": 40, "damage": 8, "gold": 25} 39 | ] 40 | 41 | 42 | def slow_print(text): 43 | for char in text: 44 | print(char, end='', flush=True) 45 | time.sleep(0.02) 46 | 47 | print() 48 | 49 | 50 | def display_stats(): 51 | print("\n" + "=" * 40) 52 | print( 53 | f"👤 Name: {player["name"]} | ❤️ Health: {player["health"]} | 💰 Gold: {player['gold']}") 54 | 55 | if player["items"]: 56 | print(f"🎒 Items: {", ".join(player["items"])}") 57 | 58 | print("=" * 40) 59 | 60 | 61 | def town(): 62 | slow_print("\n🏠 You are in town.") 63 | slow_print(locations["town"]["description"]) 64 | 65 | while True: 66 | display_stats() 67 | print("\nWhat would you like to do?") 68 | print("1. 🛒 Go to the shop") 69 | print("2. 🌲 Enter the forest") 70 | print("3. 🛏️ Rest at the inn (restore health for 10 gold)") 71 | print("4. 👋 Quit game") 72 | 73 | choice = input("> ").lower() 74 | 75 | if choice == "1" or "shop" in choice: 76 | shop() 77 | elif choice == "2" or "forest" in choice: 78 | forest() 79 | elif choice == "3" or "rest" in choice: 80 | rest() 81 | elif choice == "4" or "quit" in choice: 82 | slow_print("\n👋 Thanks for playing! Goodbye.") 83 | exit() 84 | else: 85 | print("I don't understand that option. Please try again!") 86 | 87 | 88 | def shop(): 89 | slow_print("\n🛒 You enter the shop. The shopkeeper greets you.") 90 | slow_print(locations["shop"]["description"]) 91 | 92 | while True: 93 | display_stats() 94 | print("\nWhat would you like to do?") 95 | print("1. 🧪 Buy health potion (20 gold)") 96 | print("2. ⚔️ Buy sword (50 gold)") 97 | print("3. 🚶 Return to town") 98 | 99 | choice = input("> ").lower() 100 | 101 | if choice == "1" or "health" in choice: 102 | buy_item("health potion") 103 | elif choice == "2" or "sword" in choice: 104 | buy_item("sword") 105 | elif choice == "3" or "return" in choice or "town" in choice: 106 | slow_print("\n🚶 You leave the shop and return to town.") 107 | return 108 | else: 109 | print("❓ I don't understand that. Try again.") 110 | 111 | 112 | def buy_item(item_name): 113 | item = items[item_name] 114 | 115 | # if user already bouth the item don't let them to buy again. But they can buy the health poition even if they have it already 116 | if item_name in player["items"] and item_name != "health potion": 117 | slow_print(f"\nYou already have a {item_name}") 118 | return 119 | 120 | if player["gold"] >= item["price"]: 121 | player["gold"] -= item["price"] 122 | 123 | if item_name not in player["items"]: 124 | player["items"].append(item_name) 125 | 126 | if "health" in item: 127 | slow_print( 128 | f"\n You bought a health potion! You can use it to restore {item["health"]} health!") 129 | elif 'damage' in item: 130 | slow_print( 131 | f"\n✅ You bought a {item_name}! It will help you defeat enemies faster.") 132 | else: 133 | slow_print("\n❌ You don't have enough gold to buy that item!") 134 | 135 | 136 | def forest(): 137 | slow_print("\n🌲 You enter the dark forest...") 138 | slow_print(locations["forest"]["description"]) 139 | 140 | while True: 141 | display_stats() 142 | print("\nWhat would you like to do?") 143 | print("1. 🔍 Explore deeper (chance to find treasure or enemies)") 144 | print("2. 🏠 Return to town") 145 | print("3. ⛺ Set up camp (restore 10 health)") 146 | 147 | choice = input("> ").lower() 148 | 149 | if choice == "1" or "explore" in choice: 150 | explore() 151 | elif choice == "2" or "return" in choice or "town" in choice: 152 | slow_print("\n🚶‍♂️ You leave the forest and return to town.") 153 | return 154 | elif choice == "3" or "camp" in choice: 155 | slow_print("\n⛺ You set up camp for a quick rest.") 156 | player["health"] = min(player["health"] + 10, 100) 157 | slow_print("😌 You feel a bit better. (+10 health)") 158 | else: 159 | print("I don't understand that option! Please try again.") 160 | 161 | 162 | def explore(): 163 | slow_print("\n🔍 You venture deeper into the forest...") 164 | time.sleep(1) 165 | 166 | # Random encounter: 60% chance on enemy, 30% chance on treasure and 10% on nothing 167 | encounter = random.choices( 168 | ["enemy", "treasure", "nothing"], [60, 30, 10])[0] 169 | 170 | if encounter == "enemy": 171 | enemy_encounter() 172 | elif encounter == "treasure": 173 | treasure_encounter() 174 | else: 175 | slow_print("🤷 You explore for a while but find nothing interesting.") 176 | 177 | 178 | def enemy_encounter(): 179 | enemy = random.choice(enemies) 180 | enemy_health = enemy["health"] 181 | 182 | slow_print(f"\n⚠️ You encounter a {enemy['name']}!") 183 | 184 | while enemy_health > 0 and player["health"] > 0: 185 | display_stats() 186 | print(f"\n👹 {enemy['name']} Health: {enemy_health}") 187 | print("\nWhat will you do?") 188 | print("1. ⚔️ Attack") 189 | print("2. 🧪 Use health potion") 190 | print("3. 🏃 Run away") 191 | 192 | choice = input("> ").lower() 193 | 194 | if choice == "1" or "attack" in choice: 195 | player_damage = 5 196 | if "sword" in player["items"]: 197 | player_damage += items["sword"]["damage"] 198 | 199 | enemy_health -= player_damage 200 | slow_print( 201 | f"💥 You attack the {enemy['name']} for {player_damage} damage!") 202 | 203 | if enemy_health <= 0: 204 | slow_print(f"🎉 You defeated the {enemy['name']}!") 205 | player['gold'] += enemy['gold'] 206 | slow_print(f"💰 You found {enemy['gold']} gold!") 207 | return 208 | 209 | player['health'] -= enemy['damage'] 210 | slow_print( 211 | f"😱 The {enemy['name']} attacks you for {enemy['damage']} damage!") 212 | 213 | if player['health'] <= 0: 214 | game_over() 215 | 216 | elif choice == "2" or "potion" in choice: 217 | if "health potion" in player["items"]: 218 | player['items'].remove("health potion") 219 | player['health'] = min( 220 | player['health'] + items["health potion"]["health"], 100) 221 | slow_print( 222 | f"🧪 You used a health potion and restored {items['health potion']['health']} health!") 223 | else: 224 | slow_print("❌ You don't have any health potions!") 225 | continue 226 | 227 | player['health'] -= enemy['damage'] 228 | slow_print( 229 | f"😱 The {enemy['name']} attacks you for {enemy['damage']} damage!") 230 | 231 | if player['health'] <= 0: 232 | game_over() 233 | 234 | elif choice == "3" or "run" in choice: 235 | # 50% chance to escape 236 | if random.random() > 0.5: 237 | slow_print("🏃 You managed to escape!") 238 | return 239 | else: 240 | slow_print("😨 You couldn't escape!") 241 | player['health'] -= enemy['damage'] 242 | slow_print( 243 | f"😱 The {enemy['name']} attacks you for {enemy['damage']} damage!") 244 | 245 | if player['health'] <= 0: 246 | game_over() 247 | 248 | else: 249 | print("❓ I don't understand that. Try again.") 250 | 251 | 252 | def treasure_encounter(): 253 | gold_found = random.randint(10, 30) 254 | player["gold"] += gold_found 255 | 256 | # random.random() 0.0 - 0.99 257 | if random.random() < 0.2 and "health potion" not in player["items"]: 258 | player["items"].append("health potion") 259 | slow_print("\n✨ You found a hidden treasure chest!") 260 | slow_print(f"🎁 Inside was {gold_found} gold and a health potion!") 261 | else: 262 | slow_print("\n💰 You found a small pouch with some gold inside!") 263 | slow_print(f"✨ You gained {gold_found} gold!") 264 | 265 | 266 | def rest(): 267 | if player['gold'] >= 10: 268 | player['gold'] -= 10 269 | player['health'] = 100 270 | slow_print("\n🛏️ You rest at the inn and fully recover your health.") 271 | slow_print("😊 It cost you 10 gold, but you feel completely refreshed!") 272 | else: 273 | slow_print("\n❌ You don't have enough gold to rest at the inn!") 274 | 275 | 276 | def game_over(): 277 | slow_print("\n💔 Your health has dropped to 0!") 278 | slow_print("☠️ GAME OVER!") 279 | print(f"\n📊 Final stats: {player['gold']} gold collected") 280 | 281 | play_again = input("\n🔄 Would you like to play again? (yes/no): ").lower() 282 | 283 | if play_again.startswith('y'): 284 | start_game() 285 | else: 286 | slow_print("\n👋 Thanks for playing! Goodbye.") 287 | exit() 288 | 289 | 290 | def start_game(): 291 | player["health"] = 100 292 | player["gold"] = 50 293 | player["items"] = [] 294 | 295 | slow_print("\n" + "=" * 60) 296 | slow_print("🏆 FOREST ADVENTURE 🏆") 297 | slow_print("="*60) 298 | slow_print("🎮 Welcome to a simple text adventure game!") 299 | 300 | player["name"] = input("\nWhat is your name, adventurer? ") 301 | slow_print( 302 | f"\n🎉Welcome, {player['name']}! Your adveture begins in a small town.") 303 | 304 | town() 305 | 306 | 307 | start_game() 308 | --------------------------------------------------------------------------------