A Python program that calculates package shipping costs based on the postcode and weight is shown in Figure 1.
1 shippingCost = 0
2 postcode = input("Enter your postcode: ")
3 while len(postcode) > 7:
4 errorMessage = "Invalid postcode format"
5 postcode = input(errorMessage)
6 weight = int(input("Enter package weight in kg: "))
7 if weight < 5:
8 shippingCost = 5
9 else:
10 shippingCost = weight * 1.5
11 print(shippingCost)
The shipping cost for packages weighing 5 kg or more is changed to include an additional flat-rate surcharge of £4.
Rewrite line 10 in Figure 1 to show this change.
Your answer must be written in Python.
298 exam-style questions on AQA GCSE Computer Science Programming concepts. Each one has a worked solution and a mark scheme showing where the marks go.