PYTHON PROGRAMMING LAB 3.
Electricity Bill Generator
1. Student Grade Calculator units = int(input("Enter Units Consumed: "))
if units <= 100:
Calculates total, average, and grade. bill = units * 2
elif units <= 300:
name = input("Enter student name: ")
bill = 100 * 2 + (units - 100) * 3
marks = []
else:
for i in range(5):
bill = 100 * 2 + 200 * 3 + (units - 300) * 5
mark = float(input(f"Enter mark {i+1}: "))
print("Electricity Bill = ₹", bill)
[Link](mark)
total = sum(marks)
4. Library Fine Calculator
average = total / 5
if average >= 90: days = int(input("Days Late: "))
grade = "A" if days <= 5:
elif average >= 80: fine = days * 2
grade = "B" elif days <= 10:
elif average >= 70: fine = days * 5
grade = "C" else:
elif average >= 60: fine = days * 10
grade = "D" print("Library Fine = ₹", fine)
else:
grade = "F" 5. Shopping Bill Generator
print("\nStudent:", name)
print("Total:", total) total = 0
print("Average:", average) while True:
print("Grade:", grade) price = float(input("Enter item price (0 to finish): "))
if price == 0:
2. ATM Simulator break
total += price
balance = 10000 gst = total * 0.18
while True: grand_total = total + gst
print("\n1. Check Balance") print("Subtotal:", total)
print("2. Deposit") print("GST:", gst)
print("3. Withdraw") print("Grand Total:", grand_total)
print("4. Exit")
choice = input("Choose: ") 6. Password Strength Checker
if choice == "1":
print("Balance:", balance) password = input("Enter Password: ")
elif choice == "2": if len(password) >= 8:
amount = float(input("Deposit amount: ")) print("Strong Password")
balance += amount else:
print("Deposit Successful") print("Weak Password")
elif choice == "3":
amount = float(input("Withdraw amount: ")) 7. Attendance Percentage Calculator
if amount <= balance: total_classes = int(input("Total Classes: "))
balance -= amount attended = int(input("Classes Attended: "))
print("Withdrawal Successful") percentage = (attended / total_classes) * 100
else: print("Attendance:", percentage, "%")
print("Insufficient Balance") if percentage >= 75:
elif choice == "4": print("Eligible for Exam")
break else:
else: print("Not Eligible")
print("Invalid Choice")
8. Simple Expense Tracker
expenses = [] print("Thank you for using the Bus Ticket Booking
while True: System!")
amount = float(input("Enter Expense (0 to stop): ")) break
if amount == 0: else:
break print("Invalid choice. Please try again.")
[Link](amount)
print("Total Expense:", sum(expenses))
print("Number of Expenses:", len(expenses))
9. Contact Book
contacts = {}
while True:
print("\n1. Add Contact")
print("2. View Contacts")
print("3. Exit")
choice = input("Enter choice: ")
if choice == "1":
name = input("Name: ")
phone = input("Phone: ")
contacts[name] = phone
elif choice == "2":
for name, phone in [Link]():
print(name, ":", phone)
elif choice == "3":
break
else:
print("Invalid Choice")
10. Bus Ticket Booking System
available_seats = 20
ticket_price = 350
while True:
print("\n===== Bus Ticket Booking =====")
print("1. Book Ticket")
print("2. Check Available Seats")
print("3. Exit")
choice = input("Enter your choice: ")
if choice == "1":
name = input("Enter passenger name: ")
seats = int(input("Number of seats to book: "))
if seats <= available_seats:
total = seats * ticket_price
available_seats -= seats
print("\n------ Booking Successful ------")
print("Passenger Name :", name)
print("Seats Booked :", seats)
print("Total Amount : ₹", total)
print("Seats Left :", available_seats)
else:
print("Sorry! Only", available_seats, "seats are
available.")
elif choice == "2":
print("Available Seats:", available_seats)
elif choice == "3":