RAJAPALAYAM RAJUS’ COLLEGE, RAJAPALAYAM
PG DEPARTMENT OF COMPUTER SCIENCE
BONAFIDE CERTIFICATE
NAME : CLASS :
ROLL NO : SUBJECT :
REG NO : SUB. CODE:
REGISTER NUMBER:
Certified that this is the Bonafide Certificate for Record work done
by in the COMPUTER LAB during
the Academic year 2024–2025
Signature of Signature of
Staff In-Charge Head of Department
Submitted for the University Practical Examination Held on
External Examiner
[Link]. : 1
Date:11/07/2025
ELEMENTRY DATA ITEMS [Link]. : 01
PAGE
[Link] DATE TITLE NO SIGNATURE
1 11/07/2025 ELEMENTRY DATA ITEMS 01
2 21/07/2025 CONDITIONAL BRANCHES 04
3 30/07/2025 LOOPS 06
4 06/08/2025 FUNCTIONS 09
5 19/08/2025 EXCEPTION HANDLING 13
6 09/09/2025 INHERITANCE 16
7 15/09/2025 POLYMORPHISM 18
8 23/09/2025 FILE OPERATIONS 21
9 07/10/2025 MODULES 23
AIM
To write a python program using elementary data items, lists, dictionaries and tuples.
PROGRAM
# Dictionary used to store items: item_name -> (price, stock) → uses tuple
store = {"pen": (5, 20), "notebook": (30, 10), "eraser": (3, 15)}
# List used to store cart items as tuples: (item_name, price, quantity)
cart = []
print(" Welcome to the Stationery Shop!")
while True:
print("\nAvailable Items:")
for item, (price, stock) in [Link](): # item is a string (elementary data), loop over
dictionary
print(f"{[Link]()} - ₹{price} (Stock: {stock})")
item_name = input("\nWhat do you want to buy? ").lower() # item_name is a string
(elementary data)
if item_name not in store:
print("Item not found."); continue
price, stock = store[item_name] # Tuple unpacking from dictionary value
if stock == 0:
print("Out of stock."); continue
try:
quantity = int(input("How many? ")) # quantity is an integer (elementary data)
except:
print("Invalid number."); continue
if quantity > stock:
print("Not enough stock."); continue
[Link]((item_name, price, quantity)) # Append tuple to list (cart)
store[item_name] = (price, stock - quantity) # Update dictionary with new tuple
print(f"Added {quantity} {item_name}(s) for ₹{price * quantity}")
if input("Continue shopping? (yes/done): ").lower() == "done":
break
print("\n Your Cart:")
total = 0 # total is an integer (elementary data)
for name, price, qty in cart: # Iterate over list of tuples
total += price * qty
print(f"{[Link]()} - {price} x {qty} = {price * qty}")
print(f"\nTotal: ₹{total}\nThank you for shopping!")
OUTPUT
Welcome to the Stationery Shop!
Available Items:
Pen - ₹5 (Stock: 20)
Notebook - ₹30 (Stock: 10)
Eraser - ₹3 (Stock: 15)
What do you want to buy? pen
How many? 2
Added 2 pen(s) for ₹10
Continue shopping? (yes/done): done
Your Cart:
Pen - 5 x 2 = 10
Total: ₹10
Thank you for shopping!
RESULT
Thus the above program was executed successfully.
[Link]. : 2
Date:21/07/2025
CONDITIONAL BRNCHES [Link]. : 04
AIM
To write a python program using conditional branches.
PROGRAM
age = int(input("Enter your age: "))
tickets = int(input("How many tickets do you want? "))
if age <= 0 or tickets <= 0:
print("Invalid input!")
else:
if age < 5:
price = 0
elif age <= 12:
price = 5
elif age <= 59:
price = 10
else:
price = 7
total = price * tickets
if price == 0:
print("Tickets are free! Total: $0")
else:
print(f"you are total Ticket : {tickets}")
print(f"Ticket price: ${price}")
print(f"Total amount: ${total}")
OUTPUT
Enter your age: 25
How many tickets do you want? 2
you are total Ticket : 2
Ticket price: $10
Total amount: $20
RESULT
Thus the above program was executed successfully.
[Link]. : 3
Date:30/07/2025
LOOPS [Link]. : 06
AIM
To write a python program using loops.
PROGRAM
menu = ["coffee", "tea", "juice"]
prices = {"coffee": 20, "tea": 15, "juice": 30}
orders = []
while True:
print(f"Available items: {', '.join(menu)}")
item = input("Order item (or 'stop' to finish): ").lower()
if item == "stop":
break
if item not in menu:
print("Item not available!")
continue
[Link](item)
# Final order display using nested loop
print("\nYour final order:")
total_amount = 0
for i in range(len(orders)):
for j in range(1): # inner loop runs once
item = orders[i]
price = prices[item]
print(f"{i + 1}. {item} - ${price}")
total_amount += price
# Total items and amount
print(f"\nTotal items ordered: {len(orders)}")
print(f"Total amount: ${total_amount}")
OUTPUT
Available items: coffee, tea, juice
Order item (or 'stop' to finish): tea
Available items: coffee, tea, juice
Order item (or 'stop' to finish): stop
Your final order:
1. tea - $15
Total items ordered: 1
Total amount: $15
RESULT
Thus the above program was executed successfully.
[Link]. : 4
Date:06/08/2025
FUNCTIONS [Link]. : 09
AIM
To write a python program using functions.
PROGRAM
# Global variable for account balance
balance = 1000
# Function without arguments
def show_menu():
print("\n Welcome to Simple ATM")
print("1. Check Balance")
print("2. Withdraw Money")
print("3. Exit")
# Function with argument
def withdraw(amount):
global balance
if amount > balance:
print("Insufficient balance!")
elif amount <= 0:
print("Enter a valid amount!")
else:
balance -= amount
print(f"₹{amount} withdrawn successfully.")
print(f"Remaining balance: ₹{balance}")
# Main program loop
while True:
show_menu()
choice = input("Choose an option (1-3): ").strip()
if choice == '1':
print(f"Your balance is: ₹{balance}")
elif choice == '2':
try:
amt = float(input("Enter amount to withdraw: ₹"))
withdraw(amt)
except ValueError:
print("Invalid amount!")
elif choice == '3':
print("Thank you for using the ATM. Goodbye!")
break
else:
print("Invalid option, please select 1-3.")
OUTPUT
Welcome to Simple ATM
1. Check Balance
2. Withdraw Money
3. Exit
Choose an option (1-3): 1
Your balance is: ₹1000
Welcome to Simple ATM
1. Check Balance
2. Withdraw Money
3. Exit
Choose an option (1-3): 2
Enter amount to withdraw: ₹200
₹200.0 withdrawn successfully.
Remaining balance: ₹800.0
Welcome to Simple ATM
1. Check Balance
2. Withdraw Money
3. Exit
Choose an option (1-3): 3
Thank you for using the ATM. Goodbye!
RESULT
Thus the above program was executed successfully.
[Link]. : 5
Date:19/08/2025
EXCEPTION HANDLING [Link]. : 13
AIM
To write a python program using Exception handling
PROGRAM
# Global variable for account balance
balance = 1000
# Function without arguments
def show_menu():
print("\n Welcome to Simple ATM")
print("1. Check Balance")
print("2. Withdraw Money")
print("3. Exit")
# Function with argument
def withdraw(amount):
global balance
if amount > balance:
print("Insufficient balance!")
elif amount <= 0:
print("Enter a valid amount!")
else:
balance -= amount
print(f"₹{amount} withdrawn successfully.")
print(f"Remaining balance: ₹{balance}")
# Main program loop
while True:
show_menu()
choice = input("Choose an option (1-3): ").strip()
if choice == '1':
print(f"Your balance is: ₹{balance}")
elif choice == '2':
try:
amt = float(input("Enter amount to withdraw: ₹"))
withdraw(amt)
except ValueError:
print("Invalid amount!")
elif choice == '3':
print("Thank you for using the ATM. Goodbye!")
break
else:
print("Invalid option, please select 1-3.")
OUTPUT
Welcome to Simple ATM
1. Check Balance
2. Withdraw Money
3. Exit
Choose an option (1-3): 2
Enter amount to withdraw: ₹PO
Invalid amount!
Welcome to Simple ATM
1. Check Balance
2. Withdraw Money
3. Exit
Choose an option (1-3): 3
Thank you for using the ATM. Goodbye!
RESULT
Thus the above program was executed successfully.
[Link]. : 6
Date:09/09/2025
INHERITANCE [Link]. : 16
AIM
To write a python using single and multiple inheritance.
PROGRAM
class Shape:
def __init__(self, side):
[Link] = side
class Square(Shape): # Single inheritance
def area(self):
return [Link] ** 2
class MathOps:
def perimeter(self, side):
return 4 * side
class Result(Square, MathOps): # Multiple inheritance
def show(self):
print("Area:", [Link]())
print("Perimeter:", [Link]([Link]))
n = float(input("Enter side of square: "))
r = Result(n)
[Link]()
OUTPUT
Enter side of square: 7
Area: 49.0
Perimeter: 28.0
RESULT
Thus the above program was executed successfully.
[Link]. : 7
Date:15/09/2025
POLYMORPHISM [Link]. : 18
AIM
To write a python program using polymorphism.
PROGRAM
# Base class
class Movie:
def __init__(self, tickets):
[Link] = tickets
def get_ticket_price(self):
return 0 # To be overridden
# Subclasses
class ActionMovie(Movie):
def get_ticket_price(self):
return [Link] * 150
class ComedyMovie(Movie):
def get_ticket_price(self):
return [Link] * 120
# Main Program
print("Welcome to Movie Ticket Booking!")
print("Available movies:\n- Action (₹150)\n- Comedy (₹120)")
movie_type = input("Enter movie type (action/comedy): ").lower()
tickets = int(input("How many tickets? "))
# Polymorphism: creating the right movie object
if movie_type == "action":
movie = ActionMovie(tickets)
elif movie_type == "comedy":
movie = ComedyMovie(tickets)
else:
print("Invalid movie type.")
exit()
# Output
print(f"\nYou booked {tickets} ticket(s) for {movie_type.capitalize()} movie.")
print(f"Total Price: ₹{movie.get_ticket_price()}")
OUTPUT
Welcome to Movie Ticket Booking!
Available movies:
- Action (₹150)
- Comedy (₹120)
Enter movie type (action/comedy): COMEDY
How many tickets? 2
You booked 2 ticket(s) for Comedy movie.
Total Price: ₹240
RESULT
Thus the above program was executed successfully.
[Link]. : 8
FILE OPERATIONS [Link]. : 21
Date:23/09/2025
AIM
To write a python program using file operations.
PROGRAM
import os
while True:
print("[Link] [Link] [Link] [Link] [Link]")
c = input("Choice: ")
if c == '1':
with open("[Link]","w") as f: [Link](input("Text:\n") + "\n")
elif c == '2':
try: print(open("[Link]").read())
except: print("File not found.")
elif c == '3':
with open("[Link]","a") as f: [Link](input("Append:\n") + "\n")
elif c == '4':
if [Link]("[Link]"): [Link]("[Link]"); print("Deleted")
else: print("No file")
elif c == '5':
break
else:
print("Invalid choice")
OUTPUT
[Link] [Link] [Link] [Link] [Link]
Choice: 1
Text:
SIVA
[Link] [Link] [Link] [Link] [Link]
Choice: 2
SIVA
[Link] [Link] [Link] [Link] [Link]
Choice: 3
Append:
HI
[Link] [Link] [Link] [Link] [Link]
Choice: 2
SIVA
HI
[Link] [Link] [Link] [Link] [Link]
Choice: 5
RESULT
Thus the above program was executed successfully.
[Link]. : 9
MODULES [Link]. : 23
Date:07/10/2025
AIM
To write a python program using modules.
PROGRAM
[Link]
# [Link]
def get_price(item):
if item == "apple":
return 10
if item == "banana":
return 5
return 0
# [Link]
import shop
total = 0
while True:
item = input("Buy what? (apple/banana or done): ").lower()
if item == "done":
break
price = shop.get_price(item)
if price == 0:
print("Wrong product. Try again.")
continue
qty = int(input("How many? "))
total += price * qty
print("Total is $", total)
OUTPUT
Buy what? (apple/banana or done): APPLE
How many? 2
Buy what? (apple/banana or done): DONE
Total is $ 20
RESULT
Thus the above program was executed successfully.