A programmer writes the following Python program to calculate the square of a number:
def calculate_square(num):
squared_val = num * num
return squared_val
calculate_square(4)
print(squared_val)
The programmer notices that the last line of this program does not work as expected and causes an error.
State why the line print(squared_val) does not work as expected.
33 exam-style questions on Edexcel IGCSE Computer Science Subprograms. Each one has a worked solution and a mark scheme showing where the marks go.