2Easy
0/1

A delivery company calculates shipping costs. Figure 1 shows a Python program that calculates the shipping charge based on package weight.

1  deliveryCharge = 0
2  print("Enter customer name:")
3  customerName = input()
4  while len(customerName) > 20:
5      print("Name too long")
6      customerName = input()
7  print("Enter package weight in kg:")
8  weight = int(input())
9  if weight < 5:
10     deliveryCharge = 5
11 else:
12     deliveryCharge = weight * 4
13 print(deliveryCharge)

The delivery charge for orders weighing 5kg or more is changed to include an additional flat fee of £3.

Rewrite line 12 in Figure 1 to show this change.

Your answer must be written in Python.

[1]

Arithmetic operations in a programming language Questions

Practise AQA GCSE Computer Science Arithmetic operations in a programming language with exam-style questions for GCSE Computer Science. 7 questions, matched to the AQA GCSE Computer Science (8525) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.

PreviousNext

Arithmetic operations in a programming language Questions

  1. GCSE
  2. /Computer Science
  3. /Arithmetic operations in a programming language