Medium6 marksExtended Response
ProgrammingGeneralpythoncodingselection

AQA GCSE · Question 07 · Programming

A theme park charges £15 per person for a daily ticket. If there are six or more people in a group, the group is given a £5 discount.

Write a Python program to calculate the total charge for a group of people visiting the theme park.

The program must:

  • get the user to enter the number of people in a group
  • calculate the total charge by:
    • charging £15 per person
    • reducing the total charge by £5 if there are six or more people
  • output the total charge.

You should use indentation as appropriate, meaningful variable name(s) and Python syntax in your answer.

How to approach this question

1. **Get Input:** Use the `input()` function to ask the user for the number of people. Remember to convert this input to an integer using `int()`. Store it in a variable with a meaningful name, like `num_people`. 2. **Calculate Base Cost:** Create a variable for the price per person (£15). Calculate the initial total cost by multiplying the number of people by the price per person. Store this in a variable like `total_charge`. 3. **Apply Discount:** Use an `if` statement to check if the group size (`num_people`) is greater than or equal to 6. 4. **Inside the `if` block:** If the condition is true, subtract the £5 discount from the `total_charge`. 5. **Output Result:** Use the `print()` function to display the final `total_charge` to the user. Use an f-string for clear formatting.

Full Answer

python # Get the number of people from the user num_people = int(input("Enter the number of people in the group: ")) # Calculate the initial total charge price_per_person = 15 total_charge = num_people * price_per_person # Apply discount if the group is large enough if num_people >= 6: total_charge = total_charge - 5 # Output the final charge print(f"The total charge is: £{total_charge}")
This is a standard problem that combines input, calculation, and conditional logic (selection). 1. **Input:** The program first needs to get information from the user. `num_people = int(input(...))` accomplishes this. The `input()` function gets a string, and `int()` converts it to a number for calculations. 2. **Calculation:** The base cost is calculated by simple multiplication: `total_charge = num_people * 15`. Using a variable for the price (`price_per_person = 15`) is good practice. 3. **Conditional Logic:** The core logic is the discount. An `if` statement is used to check the condition: `if num_people >= 6:`. If this is true, the code inside the indented block is executed, which subtracts 5 from the total. If it's false, the block is skipped. 4. **Output:** Finally, the result is displayed. An f-string (`f"..."`) is a modern and readable way to format strings in Python, embedding the value of the `total_charge` variable directly into the output message.

Common mistakes

✗ Forgetting to convert the user input from a string to an integer.\n✗ Using the wrong comparison operator, e.g., `>` instead of `>=`.\n✗ Applying the discount per person instead of once for the whole group.\n✗ Incorrect indentation for the `if` block.

Practice the full AQA GCSE Computer Science Paper 1 Python

31 questions · hints · full answers · grading

More questions from this exam