LearnFromHome
Login / register

Python

LearnFromHome > coding > python

Python is a popular, high-level programming language known for its readability and versatility.

150 followers

Basic Python Projects

Let’s apply what you’ve learned by building simple but fun projects: a Calculator and a Quiz Game.

Project 1: Simple Calculator

This basic calculator will take two numbers and an operator (+, -, *, /), then perform the calculation.

num1 = float(input("Enter first number: "))
operator = input("Enter operator (+, -, *, /): ")
num2 = float(input("Enter second number: "))

if operator == "+":
    print(num1 + num2)
elif operator == "-":
    print(num1 - num2)
elif operator == "*":
    print(num1 * num2)
elif operator == "/":
    if num2 != 0:
        print(num1 / num2)
    else:
        print("Cannot divide by zero")
else:
    print("Invalid operator")

Project 2: Quiz Game

This project presents multiple-choice questions and tracks the user’s score.

score = 0
questions = [
    {"question": "What is the capital of France?", "answer": "Paris"},
    {"question": "What is 5 + 7?", "answer": "12"},
    {"question": "What is the color of the sky on a clear day?", "answer": "Blue"}
]

for q in questions:
    user_answer = input(q["question"] + " ")
    if user_answer.strip().lower() == q["answer"].lower():
        print("Correct!")
        score += 1
    else:
        print("Wrong. The answer was", q["answer"])

print("You got", score, "out of", len(questions))

Next: Working with Functions →