22Medium
0/3

Complete the trace table using the program in Figure 1.

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}")
numItemspricereductionFinal output
4100[Answer 1]
5812[Answer 2]
2155[Answer 3]
[3]

Programming concepts Questions

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.

PreviousNext

Programming concepts Questions

  1. GCSE
  2. /Computer Science
  3. /Programming concepts