Complete the trace table using the program in Figure 1.
Figure 1
def calculateFee(baseRate, surcharge, multiplier):
if multiplier == 0:
return baseRate + surcharge
else:
return (baseRate + surcharge) * multiplier
# Main program execution
numOne = int(input("Enter base rate: "))
numTwo = int(input("Enter surcharge: "))
numThree = int(input("Enter multiplier: "))
charge = calculateFee(numOne, numTwo, numThree)
if numThree == 0:
print("Standard rate " + str(charge))
else:
print("Premium rate " + str(charge))
| numOne | numTwo | numThree | Final output |
|---|---|---|---|
| 15 | 5 | 0 | |
| 8 | 4 | 3 | |
| 10 | 2 | 2 |
131 exam-style questions on AQA GCSE Computer Science Structured programming and subroutines (procedures and functions). Each one has a worked solution and a mark scheme showing where the marks go.