Question 4

AQA Computer Science June 2023 Paper 1B (8525/1B)GCSE4 marks

On the specification

4.1
3.1 Fundamentals of algorithms3.2 Programming
4.2
3.2 Programming
Question text

4 Figure 3 shows a program written in Python that calculates the area of a rectangle or box the volume of a box from the user inputs. Figure 3 def calculate(width, length, height): if height == -1: return width * length else: return width * length * height numOne = int(input("Enter width: ")) numTwo = int(input("Enter length: ")) numThree = int(input("Enter height, –1 to ignore: ")) answer = calculate(numOne, numTwo, numThree) if numThree == -1: print(f"Area {answer}") else: print(f"Volume {answer}") 4.1 Complete the trace table using the program in Figure 3. [3 marks] numOne numTwo numThree Final output 56 –1 10 4 0 35 10 4.2 Describe one way that the program in Figure 3 could be made more robust. [1 mark]