0% found this document useful (0 votes)
5 views10 pages

Python Mini-Projects for Beginners

Uploaded by

fda24002
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views10 pages

Python Mini-Projects for Beginners

Uploaded by

fda24002
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

# Python Mini-Projects

# Project 1: Calculator
# Aim

To develop a simple calculator that performs basic arithmetic operations including addition,
subtraction, multiplication, and division.

# Description

This project creates an interactive calculator that allows users to select an operation and input
two numbers. The calculator performs the selected arithmetic operation and displays the result.
It includes error handling for division by zero and validates user input choices.

# Code

def calculator():

print("Simple Calculator")

print("1. Addition")

print("2. Subtraction")

print("3. Multiplication")

print("4. Division")

choice = input("Enter your choice (1/2/3/4): ")


if choice in ['1', '2', '3', '4']:

num1 = float(input("Enter first number: "))

num2 = float(input("Enter second number: "))

if choice == '1':

print(f"{num1} + {num2} = {num1 + num2}")

elif choice == '2':

print(f"{num1} - {num2} = {num1 - num2}")

elif choice == '3':

print(f"{num1} * {num2} = {num1 * num2}")

else:

if num2 != 0:

print(f"{num1} / {num2} = {num1 / num2}")

else:

print("Error! Division by zero is not allowed.")

else:
print("Invalid choice")

calculator()

#Output

Simple Calculator

1. Addition

2. Subtraction

3. Multiplication

4. Division

Enter your choice (1/2/3/4): 1

Enter first number: 15

Enter second number: 25

15.0 + 25.0 = 40.0

# Project 2: Student Grade System

# Aim

To create a system that calculates and assigns grades to students based on their marks out of
100.
#Description

This project implements a grading system that takes a student's name and marks as input, then
calculates and displays the corresponding grade. The grading scale is: A (90+), B (80-89), C
(70-79), D (60-69), and F (below 60).

#Code:-

def studentgradesystem():

print("Student Grade System")

name = input("Enter student name: ")

marks = float(input("Enter student marks (out of 100): "))

if marks >= 90:

grade = 'A'

elif marks >= 80:

grade = 'B'

elif marks >= 70:

grade = 'C'

elif marks >= 60:


grade = 'D'

else:

grade = 'F'

print(f"Student Name: {name}")

print(f"Marks: {marks}")

print(f"Grade: {grade}")

studentgradesystem()

#Output:-

Student Grade System

Enter student name: John Smith

Enter student marks (out of 100): 85

Student Name: John Smith

Marks: 85.0

Grade: B

# Project 3: Bank Transaction Simulator


#Aim

To simulate basic banking operations including deposit, withdrawal, and balance checking
functionality.

#Description

This project creates a simple banking system using object-oriented programming. It implements
a BankAccount class that maintains a balance and provides methods for deposits, withdrawals,
and balance inquiries. The simulator runs in a loop, allowing users to perform multiple
transactions until they choose to exit. It includes validation to prevent overdrafts.

#Code

class BankAccount:

def __init__(self, balance=0):

[Link] = balance

def deposit(self, amount):

[Link] += amount

print(f"Deposited ${amount}. Current balance: ${[Link]}")

def withdraw(self, amount):

if amount > [Link]:

print("Insufficient balance!")
else:

[Link] -= amount

print(f"Withdrew ${amount}. Current balance: ${[Link]}")

def check_balance(self):

print(f"Current balance: ${[Link]}")

def banktransactionsimulator():

account = BankAccount()

while True:

print("\nBank Transaction Simulator")

print("1. Deposit")

print("2. Withdraw")

print("3. Check Balance")

print("4. Exit")

choice = input("Enter your choice (1/2/3/4): ")


if choice == '1':

amount = float(input("Enter amount to deposit: "))

[Link](amount)

elif choice == '2':

amount = float(input("Enter amount to withdraw: "))

[Link](amount)

elif choice == '3':

account.check_balance()

elif choice == '4':

break

else:

print("Invalid choice")

banktransactionsimulator()

# Output of Bank Transaction Simulator

1. Deposit
2. Withdraw

3. Check Balance

4. Exit

Enter your choice (1/2/3/4): 1

Enter amount to deposit: 1000

Deposited $1000.0. Current balance: $1000.0

Bank Transaction Simulator

1. Deposit

2. Withdraw

3. Check Balance

4. Exit

Enter your choice (1/2/3/4): 2

Enter amount to withdraw: 250

Withdrew $250.0. Current balance: $750.0

Bank Transaction Simulator

1. Deposit
2. Withdraw

3. Check Balance

4. Exit

Enter your choice (1/2/3/4): 3

Current balance: $750.0

Bank Transaction Simulator

1. Deposit

2. Withdraw

3. Check Balance

4. Exit

Enter your choice (1/2/3/4): 4

# Conclusion

These Python mini-projects demonstrate fundamental programming concepts including user


input handling, conditional statements, loops, functions, and object-oriented programming. Each
project provides practical experience with real-world applications and serves as a foundation for
developing more complex systems.

You might also like