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

Python Programming Model Paper

A Model Paper For Python Programming

Uploaded by

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

Python Programming Model Paper

A Model Paper For Python Programming

Uploaded by

stemboravishka
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

COMPUTER SCIENCE EXAMINATION

Practical Programming Component: File Handling & Data Processing

Paper Duration: 2 Hours Total Marks: 50 Marks

Language Reference: Python 3.x Assessment Level: Intermediate / IGCSE Extension

Candidates Instructions:
• Answer all five questions. Each question is worth 10 marks.
• For each question, write robust, well-structured Python script files matching the requirements.
• Ensure files are opened and closed securely using best practices.
• Pay careful attention to required terminal output formatting and type conversions.

Computer Science Examination • Python File I/O Page 1 of 5


Question 1: Farm Crop Yield Analysis [10 Marks]

A local agricultural farm tracks the daily harvest weight of different crops over a week. This data is saved in a
comma-separated plain text file named harvest_data.txt. Each line represents an individual entry
formatted as: CropName,Day,WeightInKG.

File Content Specification: harvest_data.txt

Tomato,Monday,45.5
Carrot,Monday,120.0
Leek,Monday,30.2
Tomato,Tuesday,50.0
Carrot,Tuesday,115.8
Leek,Tuesday,35.5
Tomato,Wednesday,42.1
Carrot,Wednesday,130.4
Leek,Wednesday,28.9

Write a Python program that opens harvest_data.txt, reads it sequentially, and performs the following
tasks:

1. Isolate and filter the entries corresponding exclusively to the crop "Tomato".
2. Maintain a running count of the total days tomato data was recorded.
3. Calculate the total weight and the resulting average daily yield for tomatoes.
4. Output the results to the console formatted exactly as follows, ensuring numeric values display to two
decimal places:

--- Tomato Harvest Report ---


Total Days Recorded: 3
Total Weight Harvested: 137.60 kg
Average Daily Weight: 45.87 kg

Computer Science Examination • Python File I/O Page 2 of 5


Question 2: Employee Attendance & Late Log Audit [10 Marks]

An enterprise automated attendance terminal records when field staff log into work. The captured string logs
are stored inside a text file named [Link] using the structural syntax:
StaffName,ScheduledTime,ActualArrivalTime. All times utilize a strict 24-hour sequence (HH:MM).

File Content Specification: [Link]

Bandara,08:00,07:55
Ranji,08:00,08:15
Pathum,08:30,08:25
Sisil,08:00,08:05
Ranji,08:00,07:50
Sisil,08:00,08:22

Develop a Python program that reads the dataset from [Link] line by line and fulfills the following
logic specifications:

1. Identify instances where an individual's ActualArrivalTime occurs after their ScheduledTime.

2. For every flagged incident, print an explicit alert notification stating the person's name, their expected
arrival time, and their actual arrival time.
3. Track and print the overall total count of late incidents recorded throughout the entire dataset file.

Computer Science Examination • Python File I/O Page 3 of 5


Question 3: Water Pump Energy Efficiency Tracker [10 Marks]

An eco-tourism and agricultural complex runs automated irrigation manifolds. System performance logs are
appended inside power_log.txt tracking three parameters: PumpID,DurationMinutes,PowerKW.

File Content Specification: power_log.txt

Pump_A,120,3.2
Pump_B,60,5.5
Pump_A,90,3.2
Pump_C,180,1.5
Pump_B,45,5.5
Pump_A,150,3.0

Write a Python program to parse power_log.txt to assess power efficiency metrics for a specific pump
unit:

1. Filter and inspect only lines belonging to Pump_A.


2. Calculate the electricity consumption in Kilowatt-hours (kWh) for each relevant entry using the standard
metric calculation:

Energy (kWh) = Power (kW) × (Duration (Minutes) / 60)

3. Aggregate these individual values into a cumulative sum and output the final value rounded to one decimal
place.

Question 4: Aquarium Inventory Management & Stocking Alerts [10 Marks]

An ornamental fish aquaculture facility tracks live inventory thresholds in separate holding facilities. The
underlying registry file fish_inventory.txt keeps logs in the structured format:
Species,TankNumber,CurrentStock,MinRequiredStock.

File Content Specification: fish_inventory.txt

Guppy_Red,Tank_01,450,500
Neon_Tetra,Tank_02,800,600
Goldfish_Oranda,Tank_03,120,100
Guppy_Blue,Tank_04,310,400
Zebra_Danio,Tank_05,750,500

Build a Python script that acts as an automated monitoring loop to secure inventory levels:

1. Load the records and securely convert the numerical text characters into functional integer types.
2. Evaluate whether the CurrentStock value falls strictly **below** the designated MinRequiredStock
safety boundary.
3. If true, trigger an immediate command-line replenishment warning detailing the species, location tank, and
the absolute mathematical deficit (the exact amount needed to restore proper stock levels).

Computer Science Examination • Python File I/O Page 4 of 5


Question 5: Eco-Reservation Tree Planting Audit [10 Marks]

A sustainable forestry project tracking high-density Miyawaki plots uses digital logging for tracking growth
parameters. The raw collection ledger is stored in forestry_log.txt and structured as:
PlotID,TreeType,HeightCM.

File Content Specification: forestry_log.txt

Plot_East,Miyawaki_Mix,45
Plot_West,Local_Kumbuk,110
Plot_East,Miyawaki_Mix,55
Plot_North,Teak_Commercial,140
Plot_East,Miyawaki_Mix,38
Plot_West,Local_Kumbuk,95

Construct a Python script that accesses the data to perform an automated statistical evaluation on a chosen
zone:

1. Isolate entries targeting operations configured for Plot_East.


2. Process the data blocks to find the maximum height (tallest sapling) and minimum height (shortest sapling)
in that specific zone without using built-in Python collection helper features like max() or min() on lists.
3. Print out the two calculated boundaries in clear, readable notation.

Computer Science Examination • Python File I/O Page 5 of 5

You might also like