0% found this document useful (0 votes)
6 views5 pages

Python Projects

The document describes two Python projects: a Simple Banking System and a Simple Calculator. The Banking System allows users to create an account, deposit, withdraw money, and check their balance, while the Calculator provides basic arithmetic operations such as addition, subtraction, multiplication, and division. Both programs include user input validation and a menu-driven interface for interaction.

Uploaded by

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

Python Projects

The document describes two Python projects: a Simple Banking System and a Simple Calculator. The Banking System allows users to create an account, deposit, withdraw money, and check their balance, while the Calculator provides basic arithmetic operations such as addition, subtraction, multiplication, and division. Both programs include user input validation and a menu-driven interface for interaction.

Uploaded by

Vanshika Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

PYTHON PROJECT

1.Banking System

Program:

# ------------------------------
# 🏦 Simple Banking Project in Python
# Features:
# - Create an account
# - Deposit money
# - Withdraw money
# - Check balance
# ------------------------------

class BankAccount:
# Constructor to initialize account with name and balance
def __init__(self, owner, balance=0):
self.owner = owner
self.balance = balance

# Deposit money into the account


def deposit(self, amount):
if amount > 0:
self.balance += amount
print(f"✅ Successfully deposited ₹{amount}. New Balance = ₹{self.bal-
ance}")
else:
print("❌ Deposit amount must be greater than 0.")

# Withdraw money from the account


def withdraw(self, amount):
if amount <= 0:
print("❌ Withdrawal amount must be greater than 0.")
elif amount > self.balance:
print("❌ Insufficient balance! Transaction failed.")
else:
self.balance -= amount
print(f"✅ Successfully withdrew ₹{amount}. New Balance = ₹{self.bal-
ance}")

# Check current balance


def check_balance(self):
print(f"💰 Account Balance: ₹{self.balance}")

# ------------------------------
# Main Program
# ------------------------------
print("🏦 Welcome to Python Bank 🏦")

# Take account holder's name


name = input("Enter Account Holder Name: ").strip()

# Validate initial balance input


while True:
try:
initial_balance = float(input("Enter Initial Deposit (₹): "))
if initial_balance < 0:
print("❌ Balance cannot be negative. Try again.")
continue
break
except ValueError:
print("❌ Invalid input. Please enter a number.")

# Create Bank Account Object


account = BankAccount(name, initial_balance)

# Menu Loop
while True:
print("\n--- Main Menu ---")
print("1️⃣Deposit Money")
print("2️⃣Withdraw Money")
print("3️⃣Check Balance")
print("4️⃣Exit")

choice = input("Enter your choice (1-4): ")

if choice == "1":
# Deposit
try:
amt = float(input("Enter amount to deposit (₹): "))
account.deposit(amt)
except ValueError:
print("❌ Please enter a valid number.")

elif choice == "2":


# Withdraw
try:
amt = float(input("Enter amount to withdraw (₹): "))
account.withdraw(amt)
except ValueError:
print("❌ Please enter a valid number.")

elif choice == "3":


# Balance
account.check_balance()

elif choice == "4":


print(f"👋 Thank you {account.owner} for banking with us. Goodbye!")
break

else:
print("❌ Invalid choice. Please enter between 1-4.”)

Output:

1.Calculator

Program:

# ------------------------------
# 🧮 Simple Calculator in Python
# Features:
# - Addition
# - Subtraction
# - Multiplication
# - Division
# - Exit
# ------------------------------

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

# ------------------------------
# Main Program
# ------------------------------
print("🧮 Welcome to Python Calculator 🧮")

while True:
print("\n--- Calculator Menu ---")
print("1️⃣Addition")
print("2️⃣Subtraction")
print("3️⃣Multiplication")
print("4️⃣Division")
print("5️⃣Exit")

choice = input("Enter your choice (1-5): ")

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


# Get two numbers from user
try:
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
except ValueError:
print("❌ Invalid input. Please enter numbers only.")
continue

if choice == "1":
print(f"✅ Result: {num1} + {num2} = {add(num1, num2)}")
elif choice == "2":
print(f"✅ Result: {num1} - {num2} = {subtract(num1, num2)}")
elif choice == "3":
print(f"✅ Result: {num1} × {num2} = {multiply(num1, num2)}")
elif choice == "4":
print(f"✅ Result: {num1} ÷ {num2} = {divide(num1, num2)}")

elif choice == "5":


print("👋 Thank you for using Python Calculator. Goodbye!")
break

else:
print("❌ Invalid choice. Please enter a number between 1-5.”)

Output:

You might also like