Complete the trace table using the program in Figure 1.
def compute_cost(quantity, rate, discount):
if discount == 0:
return quantity * rate
else:
return (quantity * rate) - discount
numItems = int(input("Enter quantity: "))
price = int(input("Enter unit price: "))
reduction = int(input("Enter discount: "))
total = compute_cost(numItems, price, reduction)
if reduction == 0:
print(f"Standard {total}")
else:
print(f"Special {total}")
| numItems | price | reduction | Final output |
|---|---|---|---|
| 4 | 10 | 0 | [Answer 1] |
| 5 | 8 | 12 | [Answer 2] |
| 2 | 15 | 5 | [Answer 3] |
Practise AQA GCSE Computer Science Programming concepts with exam-style questions for GCSE Computer Science. 100 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.