Python Lab Exam Programs
Customer Feedback Analysis System
# Customer Feedback Analysis System
feedbacks = []
n = int(input("Enter number of customer feedbacks: "))
for i in range(n):
fb = input("Enter feedback: ").lower()
[Link](fb)
positive_words = ["good", "excellent", "great", "happy", "best"]
negative_words = ["bad", "poor", "worst", "sad", "terrible"]
positive_count = 0
negative_count = 0
for fb in feedbacks:
for word in positive_words:
if word in fb:
positive_count += 1
for word in negative_words:
if word in fb:
negative_count += 1
print("Positive Feedback Count:", positive_count)
print("Negative Feedback Count:", negative_count)
User DOB and Age Calculation
from datetime import datetime
def calculate_age(dob):
today = [Link]()
birth_date = [Link](dob, "%d-%m-%Y")
age = [Link] - birth_date.year
if ([Link], [Link]) < (birth_date.month, birth_date.day):
age -= 1
return age
name = input("Enter User Name: ")
dob = input("Enter Date of Birth (DD-MM-YYYY): ")
fav_no = input("Enter Favorite Number: ")
age = calculate_age(dob)
print("Current Age:", age)
Online Shopping Feedback System
file = open("[Link]", "a")
name = input("Enter Customer Name: ")
feedback = input("Enter Feedback: ")
rating = int(input("Enter Rating (1 to 5): "))
[Link]("Name: " + name + "\n")
[Link]("Feedback: " + feedback + "\n")
[Link]("Rating: " + str(rating) + "\n")
[Link]()
Library Book Management System
books = []
n = int(input("Enter number of books: "))
for i in range(n):
book_name = input("Enter Book Name: ")
author = input("Enter Author Name: ")
[Link]([book_name, author])
search_author = input("Enter Author Name to Search: ")
for b in books:
if b[1].lower() == search_author.lower():
print(b)
[Link]()
print("Sorted Books:", books)
Classroom Arranging System
classroom = []
rows = int(input("Enter number of rows: "))
cols = int(input("Enter number of columns: "))
seat_no = 1
for i in range(rows):
row = []
for j in range(cols):
[Link](seat_no)
seat_no += 1
[Link](row)
for r in classroom:
print(r)
Garment Product Management System
products = []
n = int(input("Enter number of products: "))
for i in range(n):
pid = int(input("Enter Product ID: "))
name = input("Enter Product Name: ")
brand = input("Enter Brand Name: ")
color = input("Enter Color: ")
price = float(input("Enter Price: "))
[Link]([pid, name, brand, color, price])
[Link](key=lambda x: x[4])
for p in products:
print(p)
Student Details Management System
students = []
n = int(input("Enter number of students: "))
for i in range(n):
reg_no = input("Enter Register Number: ")
name = input("Enter Student Name: ")
dept = input("Enter Department: ")
year = input("Enter Year: ")
student = {
"RegNo": reg_no,
"Name": name,
"Department": dept,
"Year": year
}
[Link](student)
for s in students:
print(s)
Employee Shift Swapping
emp1_shift = input("Enter Employee 1 Shift: ")
emp2_shift = input("Enter Employee 2 Shift: ")
emp1_shift, emp2_shift = emp2_shift, emp1_shift
print("After Swapping")
print(emp1_shift)
print(emp2_shift)
College Event Registration System
events = {}
n = int(input("Enter number of participants: "))
for i in range(n):
name = input("Enter Participant Name: ")
dept = input("Enter Department: ")
event = input("Enter Event Name: ")
participant = {
"Name": name,
"Department": dept
}
if event not in events:
events[event] = []
events[event].append(participant)
print(events)
ATM PIN Verification System
correct_pin = "1234"
max_attempts = 3
for attempt in range(1, max_attempts + 1):
pin = input("Enter ATM PIN: ")
if pin == correct_pin:
print("PIN Verified Successfully")
break
else:
print("Incorrect PIN")
else:
print("ATM Card Blocked")
Patient Details Management System
patient = {}
pid = input("Enter Patient ID: ")
name = input("Enter Patient Name: ")
while True:
age = int(input("Enter Age: "))
if age > 0:
break
else:
print("Invalid Age")
blood_group = input("Enter Blood Group: ")
disease = input("Enter Disease: ")
patient["Patient ID"] = pid
patient["Name"] = name
patient["Age"] = age
patient["Blood Group"] = blood_group
patient["Disease"] = disease
print(patient)
Railway Reservation using Binary Search
trains = [
[101, "Chennai Express"],
[102, "Coimbatore Express"],
[103, "Madurai Express"]
]
search_train = int(input("Enter Train Number: "))
low = 0
high = len(trains) - 1
while low <= high:
mid = (low + high) // 2
if trains[mid][0] == search_train:
print("Train Found")
break
elif trains[mid][0] < search_train:
low = mid + 1
else:
high = mid - 1
Encryption and Decryption
message = input("Enter Message: ")
encrypted = message[::-1].upper()
print("Encrypted Message:", encrypted)
decrypted = encrypted[::-1].lower()
print("Decrypted Message:", decrypted)
Supermarket Billing System
products = {
"Rice": 50,
"Sugar": 40,
"Oil": 120
}
total_bill = 0
n = int(input("Enter number of items: "))
for i in range(n):
item = input("Enter Product Name: ")
qty = int(input("Enter Quantity: "))
if item in products:
amount = products[item] * qty
total_bill += amount
print("Total Bill Amount:", total_bill)
Movie Recommendation System
movies = []
n = int(input("Enter number of movies: "))
for i in range(n):
name = input("Enter Movie Name: ")
rating = float(input("Enter Movie Rating: "))
[Link]((name, rating))
recommended = [m[0] for m in movies if m[1] >= 4]
print("Recommended Movies")
for movie in recommended:
print(movie)