Skip to content
MathsGenie logo
Open app

Course home

  1. IGCSE
  2. Computer Science Edexcel
  3. Question bank

Subprograms

EasyMedium
123
Question 3

Hassan is a library manager. He is in charge of a community library system.

Hassan has started to create a program to analyse book borrowing data.

He wants to use a modular structure with subprograms.

The program must include two subprograms with the following requirements:

  • displayOverdue(books, days): display the titles of books whose overdue duration is greater than 14 days.
  • countPopular(borrows): count and display the number of books that have been borrowed 50 or more times.

Complete the Python program code template below to implement these requirements. Do not add any further functionality.

# Library Statistics Analyzer

def displayOverdue(books, days):
    # Write your code here to display titles where days > 14

def countPopular(borrows):
    # Write your code here to count and print borrows >= 50

# --- Sample Driver Code (Do not modify) ---
book_titles = ["The Odyssey", "Frankenstein", "Dracula", "Jane Eyre"]
overdue_days = [5, 18, 14, 21]
borrow_counts = [120, 45, 62, 12]

print("Overdue books:")
displayOverdue(book_titles, overdue_days)

print("Number of popular books:")
countPopular(borrow_counts)
[7]

Subprograms Questions

  1. IGCSE
  2. /Computer Science
  3. /Subprograms