Call Us: 0800 357 9129 West Sussex, United Kingdom

Get Revising!

What is a parameter?

Data passed into a sub-routine

You can identify parameters because the names appear inbetween the brackets after the name of a sub-routine. They are used like a local variable.

Why is this sub-routine call wrong?

MySub("Holly""Twenty One",9)

The middle parameter is the incorrect data type

The data passed in must match the data type expected by the parameter.

MySub(Name, Age, x)

How many parameters must be passed to this subroutine?

Three

There are 3 parameter names in between the brackets, so 3 pieces of data must be passed in.

Why are parameters used?

To make the code reusable

By allowing different data to be passed into sub-routines, parameters make the code re-usable saving time & memory.

Why is this sub-routine call wrong?

MySub("Holly",21)

There are only 2 parameters

MySub() required 3, so this would produce an error.

The code below already uses a subroutine to create an Easter Bunny name generator. The WHILE loop means that the bottom three lines will repeat infinately because True always = True. This means that the subroutine can be called over and over again with new values but without having to write any extra code.

Update this so that the user enters their name and the first & second letter of their name are used to calculate the bunny name using this pseudocode, then explain in your assignment why the ORD function and MOD operators have been used here:

WHILE True:
    name <-- int(input("Enter a number between 0 & 4"))
    number1 <-- ORD(name[0]) MOD 5
    number2 <-- ORD(name[1]) MOD 5  

    easterBunnyName(number1,number2)

Sub-routines are really helpful for running calculations on similar pieces of data without needing to write the code more than once. The code below has started to write a program that takes in some data and calls four different sub-routines to manipulate the data in different ways.

hint: whilst you write each sub-routine, you may want to add a # in front of the incomplete def statements to allow the code to run.

Download Scribbl.it Notes

The Programming Parameters Scribbl.it Notes provide a structured way for you to revise topic areas in a visual way. You don’t have to be an artist as it’s all been drawn out for you (or you can use this as inspiration to create your own!). Print the notes, then colour in areas of importance, add doodles and colour, then add more detail to the notes page being as creative as possible.

There are known benefits to using Scribbl.it Notes (whether structured like these, or independently created):

  • Increased Attention
  • Reduction of stress levels
  • Increased memory for content
  • Deeper learning

Scroll to the bottom to download

Resize Text
High Contrast