01 – Real – World Python Projects – Calculator / Quiz App

๐ŸŽฏ Project Objective

To build beginner-friendly, real-world applications in Python that demonstrate:

  • Logic implementation
  • Input/output handling
  • Loops, conditionals, and functions
  • User interaction

Project 1: Calculator App

Project Description

A basic calculator that performs operations like addition, subtraction, multiplication, and division. The app can run in a loop, allowing the user to perform multiple calculations.

Features

  • Add, subtract, multiply, divide numbers
  • Handle division by zero errors
  • User-friendly interface via console

Python Example Code

def add(a, b):
    return a + b

def subtract(a, b):
    return a - b

def multiply(a, b):
    return a * b

def divide(a, b):
    if b == 0:
        return "Error! Division by zero."
    return a / b

print("Welcome to Python Calculator!")
while True:
    print("\nOptions: +, -, *, / or 'q' to quit")
    choice = input("Choose operation: ")

    if choice == 'q':
        print("Exiting Calculator. Goodbye!")
        break

    if choice in ('+', '-', '*', '/'):
        num1 = float(input("Enter first number: "))
        num2 = float(input("Enter second number: "))

        if choice == '+':
            print("Result:", add(num1, num2))
        elif choice == '-':
            print("Result:", subtract(num1, num2))
        elif choice == '*':
            print("Result:", multiply(num1, num2))
        elif choice == '/':
            print("Result:", divide(num1, num2))
    else:
        print("Invalid input! Try again.")

โœ… Learning Points

  • Functions for modularity
  • Error handling
  • Loops and user input

Project 2: Quiz App

Project Description

A console-based quiz app that asks multiple-choice questions and tracks the score.

Features

  • Ask 5โ€“10 questions
  • Multiple-choice answers
  • Display score at the end
  • Friendly user interface

Python Example Code

questions = [
    {
        "question": "What is the capital of France?",
        "options": ["A. Paris", "B. London", "C. Berlin", "D. Madrid"],
        "answer": "A"
    },
    {
        "question": "Which language is used for web apps?",
        "options": ["A. Python", "B. HTML", "C. JavaScript", "D. All of the above"],
        "answer": "D"
    },
    {
        "question": "What is 5 + 7?",
        "options": ["A. 10", "B. 12", "C. 13", "D. 14"],
        "answer": "B"
    }
]

score = 0

print("Welcome to the Python Quiz!\n")

for q in questions:
    print(q["question"])
    for option in q["options"]:
        print(option)
    answer = input("Your answer (A/B/C/D): ").upper()
    if answer == q["answer"]:
        print("Correct!\n")
        score += 1
    else:
        print(f"Wrong! Correct answer: {q['answer']}\n")

print(f"Quiz Finished! Your Score: {score}/{len(questions)}")

โœ… Learning Points

  • Lists and dictionaries
  • Loops and conditionals
  • Input validation
  • Scoring mechanism


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *