Skip to content
MathsGenie logo
Open app

Course home

  1. IGCSE
  2. Computer Science Edexcel
  3. Question bank

Subprograms

EasyMedium
123456789101112131415161718192021222324252627282930
Question 1

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.

[1]

Subprograms Questions

  1. IGCSE
  2. /Computer Science
  3. /Subprograms