Beginner Python Projects: Mastering Core Concepts
Project 1: Simple Calculator
Problem Statement:
Create a simple calculator that asks the user for two numbers and an arithmetic operation (addition,
subtraction, multiplication, or division), then displays the result.
Concepts Used:
• Variables
• Data types (int, float)
• Input function
• Arithmetic operators
• Type conversion
Code Example:
# Welcome message
print("Welcome to the Simple Calculator!")
# Taking input from the user and converting it to float
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
# Asking the user for the operation
operation = input("Enter the operation (+, -, *, /): ")
# Performing the calculation based on user input
if operation == '+':
result = num1 + num2
elif operation == '-':
result = num1 - num2
elif operation == '*':
result = num1 * num2
elif operation == '/':
result = num1 / num2
else:
result = "Invalid operation"
# Displaying the result
print("The result is:", result)
Explanation:
1. The program starts by asking the user to input two numbers, which are then converted from
string format (the default from input()) to float using float().
2. The user is then asked to input an arithmetic operation (+, -, *, or /), stored as a string.
3. Using if-elif conditions, the appropriate arithmetic operation is performed.
4. Finally, the result of the calculation is printed.
Project 2: Temperature Converter
Problem Statement:
Write a program that converts temperatures from Celsius to Fahrenheit. The user will input a
temperature in Celsius, and the program will output the temperature in Fahrenheit.
Concepts Used:
• Variables
• Data types (float, str)
• Input function
• Arithmetic operators
• Type conversion
Code Example:
# Welcome message
print("Celsius to Fahrenheit Converter")
# Taking input in Celsius from the user
celsius = float(input("Enter temperature in Celsius: "))
# Converting Celsius to Fahrenheit using the formula
fahrenheit = (celsius * 9/5) + 32
# Displaying the result
print("The temperature in Fahrenheit is:", fahrenheit)
Explanation:
1. The program starts by taking a temperature value in Celsius as input from the user and
converts it to a float.
2. The formula for converting Celsius to Fahrenheit is applied: Fahrenheit = (Celsius * 9/5) + 32.
3. The result is printed.
Project 3: BMI Calculator
Problem Statement:
Create a program that calculates a user's Body Mass Index (BMI) based on their height and weight.
Concepts Used:
• Variables
• Data types (int, float)
• Input function
• Arithmetic operators
• Type conversion
Code Example:
# Welcome message
print("BMI Calculator")
# Taking weight and height input from the user
weight = float(input("Enter your weight in kilograms: "))
height = float(input("Enter your height in meters: "))
# Calculating BMI using the formula
bmi = weight / (height ** 2)
# Displaying the BMI result
print("Your BMI is:", bmi)
Explanation:
1. The program first asks for the user's weight and height, which are input as floats.
2. The BMI formula is applied: BMI = weight / (height ** 2).
3. The calculated BMI is printed.
Project 4: Age Checker
Problem Statement:
Write a program that takes a user’s birth year and current year, then calculates their age and checks
if they are 18 or older.
Concepts Used:
• Variables
• Data types (int, str)
• Input function
• Comparison operators
• Type conversion
Code Example:
# Welcome message
print("Age Checker")
# Taking birth year and current year as input from the user
birth_year = int(input("Enter your birth year: "))
current_year = int(input("Enter the current year: "))
# Calculating the age
age = current_year - birth_year
# Checking if the user is 18 or older
if age >= 18:
print("You are an adult.")
else:
print("You are not an adult yet.")
# Displaying the user's age
print("Your age is:", age)
Explanation:
1. The program takes the user's birth year and the current year as input and converts them into
integers.
2. It calculates the age by subtracting the birth year from the current year.
3. The program checks if the user is 18 or older using a comparison operator and prints the
result.
Project 5: Simple Interest Calculator
Problem Statement:
Create a program that calculates the simple interest given the principal amount, rate of interest, and
time (in years).
Concepts Used:
• Variables
• Data types (float, int)
• Input function
• Arithmetic operators
• Type conversion
Code Example:
# Welcome message
print("Simple Interest Calculator")
# Taking input from the user
principal = float(input("Enter the principal amount: "))
rate_of_interest = float(input("Enter the rate of interest: "))
time = int(input("Enter the time in years: "))
# Calculating the simple interest using the formula
simple_interest = (principal * rate_of_interest * time) / 100
# Displaying the simple interest
print("The simple interest is:", simple_interest)
Explanation:
1. The program asks for the principal amount, rate of interest, and time from the user.
2. The simple interest formula is applied: Simple Interest = (P * R * T) / 100.
3. The result is printed.
Project 6: Price Calculator
Problem Statement:
Write a program that takes the price of an item and the tax percentage, and calculates the final price
after tax.
Code Example:
# Welcome message
print("Price Calculator")
# Taking input from the user
price = float(input("Enter the price of the item: "))
tax_percentage = float(input("Enter the tax percentage: "))
# Calculating the final price after tax
final_price = price + (price * tax_percentage / 100)
# Displaying the final price
print("The final price after tax is:", final_price)
Explanation:
1. The user inputs the price of an item and the tax percentage.
2. The program calculates the tax using the formula price * tax_percentage / 100 and adds it to
the original price.
3. The final price is printed.
Project 7: Area of a Circle
Problem Statement:
Write a program that calculates the area of a circle given its radius.
Code Example:
# Welcome message
print("Area of a Circle Calculator")
# Taking the radius as input from the user
radius = float(input("Enter the radius of the circle: "))
# Calculating the area using the formula
area = 3.14159 * (radius ** 2)
# Displaying the area
print("The area of the circle is:", area)
Explanation:
1. The user inputs the radius of the circle.
2. The formula for the area of a circle (πr²) is applied, where π is approximated to 3.14159.
3. The result is printed.
Project 8: Simple Percentage Calculator
Problem Statement:
Write a program that calculates the percentage of a given number.
Code Example:
# Welcome message
print("Percentage Calculator")
# Taking the number and percentage as input
total_number = float(input("Enter the total number: "))
percentage = float(input("Enter the percentage to calculate: "))
# Calculating the percentage
result = (total_number * percentage) / 100
# Displaying the result
print(percentage, "% of", total_number, "is:", result)
Explanation:
1. The user inputs a number and the percentage.
2. The percentage is calculated using the formula (total_number * percentage) / 100.
3. The result is printed.
Project 9: Time Converter (Minutes to Hours)
Problem Statement:
Write a program that converts time from minutes to hours and minutes.
Code Example:
# Welcome message
print("Minutes to Hours Converter")
# Taking input from the user
minutes = int(input("Enter the time in minutes: "))
# Calculating hours and remaining minutes
hours = minutes // 60
remaining_minutes = minutes % 60
# Displaying the result
print(minutes, "minutes is equal to", hours, "hours and", remaining_minutes, "minutes.")
Explanation:
1. The user inputs time in minutes.
2. Integer division (//) is used to calculate the number of hours, and the modulo operator (%)
finds the remaining minutes.
3. The result is printed.
Project 10: Total Marks and Average Calculator
Problem Statement:
Write a program that takes the marks of three subjects and calculates the total marks and average.
Code Example:
# Welcome message
print("Marks and Average Calculator")
# Taking input for three subjects
subject1 = float(input("Enter the marks for Subject 1: "))
subject2 = float(input("Enter the marks for Subject 2: "))
subject3 = float(input("Enter the marks for Subject 3: "))
# Calculating total and average
total_marks = subject1 + subject2 + subject3
average_marks = total_marks / 3
# Displaying the total and average
print("Total marks:", total_marks)
print("Average marks:", average_marks)
Explanation:
1. The user inputs marks for three subjects.
2. The total marks are calculated by adding all three, and the average is calculated by dividing
the total by 3.
3. The result is printed.
Project 11: Currency Converter (USD to INR)
Problem Statement:
Write a program that converts a given amount from USD to INR.
Code Example:
# Welcome message
print("USD to INR Converter")
# Taking input from the user
usd = float(input("Enter amount in USD: "))
# Assuming conversion rate is 1 USD = 82 INR
inr = usd * 82
# Displaying the result
print(usd, "USD is equal to", inr, "INR.")
Explanation:
1. The user inputs an amount in USD.
2. The conversion is done using the rate 1 USD = 82 INR.
3. The result is printed.
Project 12: Product of Three Numbers
Problem Statement:
Write a program that calculates the product of three numbers.
Code Example:
# Welcome message
print("Product of Three Numbers")
# Taking input for three numbers
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
num3 = float(input("Enter the third number: "))
# Calculating the product
product = num1 * num2 * num3
# Displaying the product
print("The product of the three numbers is:", product)
Explanation:
1. The user inputs three numbers.
2. The product is calculated using multiplication.
3. The result is printed.
Project 13: Grade Calculator
Problem Statement:
Write a program that calculates the grade based on the percentage of marks.
Code Example:
# Welcome message
print("Grade Calculator")
# Taking input for the percentage
percentage = float(input("Enter your percentage: "))
# Determining the grade based on the percentage
if percentage >= 90:
grade = 'A'
elif percentage >= 80:
grade = 'B'
elif percentage >= 70:
grade = 'C'
elif percentage >= 60:
grade = 'D'
else:
grade = 'F'
# Displaying the grade
print("Your grade is:", grade)
Explanation:
1. The user inputs the percentage of marks.
2. Conditional statements are used to assign grades based on percentage ranges.
3. The result is printed.
Project 14: Compound Interest Calculator
Problem Statement:
Write a program that calculates compound interest given principal, rate, and time.
Code Example:
# Welcome message
print("Compound Interest Calculator")
# Taking input from the user
principal = float(input("Enter the principal amount: "))
rate = float(input("Enter the annual rate of interest: "))
time = int(input("Enter the time in years: "))
# Calculating compound interest
amount = principal * (1 + rate / 100) ** time
compound_interest = amount - principal
# Displaying the compound interest
print("The compound interest is:", compound_interest)
Explanation:
1. The user inputs the principal, rate, and time.
2. The formula for compound interest A = P(1 + r/n)^(nt) is simplified to A = P(1 + r)^t for
annual interest.
3. The result is printed.
Project 15: Discount Calculator
Problem Statement:
Write a program that calculates the discount given the original price and discount percentage.
Code Example:
# Welcome message
print("Discount Calculator")
# Taking input for price and discount percentage
original_price = float(input("Enter the original price: "))
discount_percentage = float(input("Enter the discount percentage: "))
# Calculating the discount and final price
discount_amount = (original_price * discount_percentage) / 100
final_price = original_price - discount_amount
# Displaying the final price
print("The final price after discount is:", final_price)
Explanation:
1. The user inputs the original price and discount percentage.
2. The discount amount is calculated using the formula (price * discount_percentage) / 100.
3. The final price after discount is printed.
These are the first 10 additional projects to add to the list. I'll continue building out the rest for you.
Project 16: Voting Eligibility Checker
Problem Statement:
Write a program that checks whether the user is eligible to vote based on their age.
Code Example:
# Welcome message
print("Voting Eligibility Checker")
# Taking input from the user
age = int(input("Enter your age: "))
# Checking voting eligibility
if age >= 18:
print("You are eligible to vote.")
else:
print("You are not eligible to vote yet.")
Explanation:
1. The program asks for the user's age.
2. The program checks if the user is 18 or older using an if-else statement.
3. The result is printed.
Project 17: Average Speed Calculator
Problem Statement:
Write a program that calculates the average speed based on distance traveled and time taken.
Code Example:
# Welcome message
print("Average Speed Calculator")
# Taking input for distance and time
distance = float(input("Enter the distance traveled (in km): "))
time = float(input("Enter the time taken (in hours): "))
# Calculating average speed
average_speed = distance / time
# Displaying the average speed
print("The average speed is:", average_speed, "km/h")
Explanation:
1. The user inputs the distance traveled and time taken.
2. The average speed is calculated using the formula distance / time.
3. The result is printed.
Project 18: Age in Days Calculator
Problem Statement:
Write a program that calculates a person's age in days based on their birth year.
Code Example:
# Welcome message
print("Age in Days Calculator")
# Taking birth year and current year as input
birth_year = int(input("Enter your birth year: "))
current_year = int(input("Enter the current year: "))
# Calculating the age in years and converting it to days
age_in_years = current_year - birth_year
age_in_days = age_in_years * 365
# Displaying the age in days
print("You are", age_in_days, "days old.")
Explanation:
1. The user inputs their birth year and the current year.
2. The age in years is calculated and multiplied by 365 to convert it to days.
3. The result is printed.
Project 19: Distance Between Two Points
Problem Statement:
Write a program that calculates the distance between two points on a 2D plane given their
coordinates.
Code Example:
# Welcome message
print("Distance Between Two Points Calculator")
# Taking the coordinates as input
x1 = float(input("Enter x1: "))
y1 = float(input("Enter y1: "))
x2 = float(input("Enter x2: "))
y2 = float(input("Enter y2: "))
# Calculating the distance using the formula
distance = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
# Displaying the distance
print("The distance between the two points is:", distance)
Explanation:
1. The program takes the coordinates of two points as input.
2. The distance formula (x2 - x1)^2 + (y2 - y1)^2 is used to calculate the distance.
3. The result is printed.
Project 20: Leap Year Checker
Problem Statement:
Write a program that checks whether a given year is a leap year.
Code Example:
# Welcome message
print("Leap Year Checker")
# Taking input from the user
year = int(input("Enter a year: "))
# Checking if the year is a leap year
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
print(year, "is a leap year.")
else:
print(year, "is not a leap year.")
Explanation:
1. The program takes the year as input.
2. The leap year condition is checked using the rules: divisible by 4 and not by 100, or divisible
by 400.
3. The result is printed.
Project 21: Unit Converter (Kilometers to Miles)
Problem Statement:
Write a program that converts a given distance from kilometers to miles.
Code Example:
# Welcome message
print("Kilometers to Miles Converter")
# Taking input from the user
kilometers = float(input("Enter distance in kilometers: "))
# Conversion factor: 1 kilometer = 0.621371 miles
miles = kilometers * 0.621371
# Displaying the result
print(kilometers, "kilometers is equal to", miles, "miles.")
Explanation:
1. The program takes the distance in kilometers as input.
2. It converts the distance to miles using the conversion factor 1 kilometer = 0.621371 miles.
3. The result is printed.
Project 22: Tip Calculator
Problem Statement:
Write a program that calculates the tip amount based on the bill amount and tip percentage.
Code Example:
# Welcome message
print("Tip Calculator")
# Taking input from the user
bill_amount = float(input("Enter the bill amount: "))
tip_percentage = float(input("Enter the tip percentage: "))
# Calculating the tip
tip = (bill_amount * tip_percentage) / 100
total_amount = bill_amount + tip
# Displaying the tip and total amount
print("Tip amount:", tip)
print("Total amount to be paid:", total_amount)
Explanation:
1. The program asks for the bill amount and tip percentage.
2. It calculates the tip using (bill_amount * tip_percentage) / 100 and adds it to the bill.
3. The result is printed.
Project 23: Fahrenheit to Celsius Converter
Problem Statement:
Write a program that converts a given temperature from Fahrenheit to Celsius.
Code Example:
# Welcome message
print("Fahrenheit to Celsius Converter")
# Taking input from the user
fahrenheit = float(input("Enter temperature in Fahrenheit: "))
# Converting Fahrenheit to Celsius using the formula
celsius = (fahrenheit - 32) * 5/9
# Displaying the result
print(fahrenheit, "Fahrenheit is equal to", celsius, "Celsius.")
Explanation:
1. The program takes the temperature in Fahrenheit as input.
2. It converts the temperature to Celsius using the formula (Fahrenheit - 32) * 5/9.
3. The result is printed.
Project 24: Volume of a Cylinder
Problem Statement:
Write a program that calculates the volume of a cylinder given its radius and height.
Code Example:
# Welcome message
print("Cylinder Volume Calculator")
# Taking input from the user
radius = float(input("Enter the radius of the cylinder: "))
height = float(input("Enter the height of the cylinder: "))
# Calculating the volume using the formula
volume = 3.14159 * (radius ** 2) * height
# Displaying the volume
print("The volume of the cylinder is:", volume)
Explanation:
1. The program takes the radius and height of the cylinder as input.
2. It calculates the volume using the formula πr²h.
3. The result is printed.
Project 25: BMI Category Checker
Problem Statement:
Write a program that takes the user's BMI and determines their BMI category (Underweight, Normal,
Overweight, Obese).
Code Example:
# Welcome message
print("BMI Category Checker")
# Taking the user's BMI as input
bmi = float(input("Enter your BMI: "))
# Checking the BMI category
if bmi < 18.5:
category = "Underweight"
elif bmi < 24.9:
category = "Normal weight"
elif bmi < 29.9:
category = "Overweight"
else:
category = "Obese"
# Displaying the category
print("Your BMI category is:", category)
Explanation:
1. The program takes the user's BMI as input.
2. It uses if-elif conditions to determine the BMI category based on the input.
3. The result is printed.
Project 26: Rectangle Area and Perimeter
Problem Statement:
Write a program that calculates the area and perimeter of a rectangle given its length and width.
Code Example:
# Welcome message
print("Rectangle Area and Perimeter Calculator")
# Taking input for length and width
length = float(input("Enter the length of the rectangle: "))
width = float(input("Enter the width of the rectangle: "))
# Calculating area and perimeter
area = length * width
perimeter = 2 * (length + width)
# Displaying the area and perimeter
print("Area of the rectangle:", area)
print("Perimeter of the rectangle:", perimeter)
Explanation:
1. The user inputs the length and width of the rectangle.
2. The area is calculated as length * width, and the perimeter as 2 * (length + width).
3. The result is printed.
Project 26: Rectangle Area and Perimeter
Problem Statement:
Write a program that calculates the area and perimeter of a rectangle given its length and width.
Code Example:
python
Copy code
# Welcome message
print("Rectangle Area and Perimeter Calculator")
# Taking input for length and width
length = float(input("Enter the length of the rectangle: "))
width = float(input("Enter the width of the rectangle: "))
# Calculating area and perimeter
area = length * width
perimeter = 2 * (length + width)
# Displaying the area and perimeter
print("Area of the rectangle:", area)
print("Perimeter of the rectangle:", perimeter)
Explanation:
1. The user inputs the length and width of the rectangle.
2. The area is calculated as length * width, and the perimeter as 2 * (length + width).
3. The result is printed.