Skip to content
MathsGenie logo
Open app

Course home

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

Subprograms

EasyMedium
123
Question 1

A local sports club needs to generate unique member codes for its members.

Open the code editor or write the amended code for the program below to:

  1. Complete the subprogram generate_member_code to construct and return the code using these rules:
    • The first 2 characters of the first_name in uppercase
    • The first 3 characters of the surname in uppercase
    • The last 2 characters of the join_year (passed as a string)
  2. Complete the call to the subprogram in the main program, passing the correct arguments and assigning the result to the variable member_code.
def generate_member_code(first_name, surname, join_year):
    # Only write code inside this subprogram to generate the member code

# Main Program\nuser_first = "David"\nuser_surname = "Miller"
year = "2025"

# Complete the call to the subprogram below
member_code =

print("Generated Code: " + member_code)

Save your code as Q04cFINISHED after completing the amendments.

[6]

Subprograms Questions

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