Zoom
Kizspy.me
PRACTICAL EXAM - PRP201c - SP25
Duration: 120 minutes
Lab Reservation Analysis with Python
Lib allowed: Python (csv, sqlite3, matplotlib, datetime)
Instructions:
You will use a .txt file named lab_reservation.txt.
The file contains reservation records of students using lab rooms.
Each question asks you to write a Python program or function.
Submit a .py file with your solutions.
Do not use Al tools or the internet. Your work must be your own.
Question 1. Load and Print Reservation Summary (1.5 marks)
• First, read the lab_reservation.txt file and print a summary showing: Total number of
reservations, Number of unique rooms, Date range of the reservations.
[At the beginning of your .py file, read the lab_reservation.txt file using
csv. DictReader and store the records in a list named reservations. This list must be
used as input to all other questions.]
import csv
with open("lab_reservation.txt", "", encoding="utf-8") as file:
reader = csv. DictReader(file)
reservations list(reader)
Question 2. Find Busiest Room (1 mark)
• Write a function to find the room that has the most reservations. Print the room name
and total number of bookings..
Question 3. Get Morning Reservations (1 mark)
• A reservation is considered morning if the time slot is before 12:00. Write a function
that returns a list of all reservations in the morning and print the number of such
bookings.
Question 4: Export Morning Reservations (1.5 marks)
• Export all morning reservations (from Q3) into a file called morning_reservations.csv
with the original 5 columns. Include a header row.
Question 5. Store Reservations in SQLite (1.5 marks)
• Create a SQLite database lab.db and a table reservations with columns: id
(INTEGER PRIMARY KEY AUTOINCREMENT), student_id, student_name, room,
date, time slot Insert all data from the file into the database.
Question 6. Query Afternoon in Deep Blue Lab (1 mark)
•
Write a SQL query using Python to retrieve and print all reservations made in Deep
Blue Lab after 12:00. Print student name, date, and time slot.
Question 7: Generate Booking Statistics (1.5 marks)
• Write a function that prints: Number of reservations per room, Number of
100%
Close