Skip to content

Course home

Sign up

Develop code

EasyMediumHard
1234567891011121314151617
Question 15

A program is required to calculate the total registration fee for an event. Bookings are made either as individual tickets or as corporate exhibition floor space.

The user enters the number 10 if the booking is for individual tickets or the number 20 if the booking is for corporate floor space. The user then enters either the number of tickets (an integer) or the exhibition floor area in square meters (a real number).

The program checks for invalid input. If the input is valid, the program calculates and displays the total fee.

Currency formatting with two decimal places and a currency symbol is not required.

Table 1: Test cases and expected outputs

Booking categoryTicket countFloor areaOutput
103Total fee is 37.5
100Invalid number of tickets
204.5Total fee is 384.75
20-3.2Invalid floor area
15Invalid booking type

Open file Q03.py which contains the following skeletal code:

# TODO: create an integer variable named bookingType and set it to 0

TICKET_PRICE = 12.50
SPACE_RATE = 85.50

bookingType = int(input("Enter booking type (10 or 20): "))

if bookingType != 10 [operator] bookingType != [constant]:
    print("Invalid booking type")
else:
    if bookingType == 10:
        count = int(input("Enter number of tickets: "))
        if [check for 0 or negative count]:
            print("Invalid number of tickets")
        else:
            total = count * TICKET_PRICE
            print("Total fee is " + str(total))
    elif bookingType == [constant]:
        area = [accept a real value for area]
        if area [relational operator] 0:
            print("Invalid floor area")
        else:
            total = [calculate total fee based on floor space]
            # TODO: add a line to display an informative message and the total fee

Amend the code to:

  • Create an integer variable named bookingType and set it to 0.
  • Complete a line with the correct logical operator and the correct constant.
  • Complete a line with the correct constant.
  • Complete a line to accept a real (float) value for the exhibition space area.
  • Complete a line to calculate the total fee based on floor space area.
  • Complete a line to check for a 0 or negative ticket count.
  • Complete a line with the correct relational operator.
  • Add a line to display an informative message and the total fee.

Do not add any additional functionality.

Save your amended code as Q03FINISHED.py

[10]
Markscheme

Develop code Questions

  1. GCSE
  2. /Computer Science
  3. /Develop code

51 exam-style questions on Edexcel GCSE Computer Science Develop code, covering Decomposition and abstraction to solve problems, Read, write, analyse and refine programs, Converting algorithms into programs, Techniques for readable, maintainable code, Identifying and correcting program errors, and Evaluating program fitness and efficiency. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank