0% found this document useful (0 votes)
27 views2 pages

A0 Worksheet ÔÇô Make A Prediction (Repaired)

Uploaded by

iwujiterry3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

A0 Worksheet ÔÇô Make A Prediction (Repaired)

Uploaded by

iwujiterry3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

KS4 - Programming Activity sheet

Lesson 18 - Subroutines

Annotate the code:

1 def calculate(a, b):


2 answer = a + b
3 print(f"{a} + {b} = {answer}")
4
5 num1 = 10
6 num2 = 15
7
8 calculate(num1, num2)

Task .

Line 1 is defining the function of the variables and saying what it should do.
They are local variables because they can’t be used outside the subroutine.
Line 2 is defining what answer is. It is saying answer should be the addition
between A and B
Line 3 is the print statement is going to print out the addition between a and b
and also the answer.
Line 5 is giving num1 a value and defining what num1 is. It is a global variable
as it can be used anywhere in the program
Line 6 is giving num2 a value and defining what num2 is. It is a global variable
as it can be used anywhere in the program
Line 8 is going to calculate the addition between num1 and num2 and answer
it and print it out.

Page 1 Last updated: 17-05-21


KS4 - Programming Activity sheet
Lesson 18 - Subroutines

Page 2 Last updated: 17-05-21

You might also like