Skip to content

Course home

Arithmetic operations in a programming language

Arithmetic operations in a programming language

EasyMedium
12345
Question 2

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]
Markscheme

Arithmetic operations in a programming language Questions

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

7 exam-style questions on AQA GCSE Computer Science Arithmetic operations in a programming language. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank