Page 53 - Touchcode_C7_Flipbook
P. 53
Step 4: From the ‘Variables’ select ‘set cube
to 0’ block. Drag ‘set cube to 0’, and
drop it to the ‘function ’Cube of a
number’block. From the ‘Math’ block,
select ‘multiplication’ block two times.
From ‘Variables’ select variable ‘num1’ three times. Drag variable ‘num1’ and
drop them to ‘multiply’ block. Now, drag the multiplication block to ‘0’ of ‘set
cube to 0’ block.
Step 5: From ‘Function’ select ‘return’ block, and drag the variable ‘cube’ and drop it on the
‘0’ of ‘return’ block. Drag and drop the ‘return’ block to ‘function- Cube of a number’.
Step 6: In the same way, create a function ‘Square of a number’.
Step 7: From the ‘Function’ select ‘call Square of a number’ and ‘call Cube of a number‘,
drop them to ‘set var1 and set var2’. In ‘set var3’, drag and drop addition block
and in ‘0’ drag the variable ‘var1’ and ‘var2’.
Step 8: From ‘Game’, select ‘splash’ block. Click on ‘Advanced’, select ‘Text’, and then click
on ‘join’ block. Drag the ‘join’ block and drop it to the ‘splash’ block.
Step 9: Type the message ‘Output is:’ in ‘hello’ and in ‘world’ drag the variable ‘var3’, and
drop it in a ‘join’ block.
Fun with Functions 51

