0% found this document useful (0 votes)
12 views7 pages

Lesson 5 Digi Trailblazers Course 2

Uploaded by

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

Lesson 5 Digi Trailblazers Course 2

Uploaded by

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

Lesson 5 - Modular Code

Course 2
Inspiring the next generation of digital innovators
Lesson 5 – Modular Code

By the end of the lesson you will understand more about:

• How to write modular code

03
Activity 1

• The code demonstrates


the creation, call and
recall of a user-defined
function.

• The program displays


the stock levels of
products A to E. The
data is in the form of a
bar chart. The user
inputs the symbol to be
used for the bar chart.

• Key in, debug and


04 execute the code.
Terminology

• Function call - Where the user defined function (or a library


function) is activated in the main body of the program

• Function definition - where code is created that can be


reused; it is separate from the main body of the program

• Parameter - the value passed into a function when it starts,


or passed back out when the function is complete

05
• Defining functions
• All functions begin with def

Lesson Summary •
Not all functions have input and output parameters
Functions are called when needed
• If there are parameters, the parameters should be in the
– Understand same order as the function call

How to Write • Calling functions


Modular Code • Functions with output parameters may need to be captured
in a variable.
• Functions without parameters can simply be called:

MyFunction()

06
NCC Education Head South Africa Malaysia China Singapore
Office UK 1 Bridgeway Road Unit No.C-7-4 LG2-T1, Tower C 100 Victoria Street
The Towers Bridgeways Precinct Wisma Goshen, Plaza Pantai COFCO Plaza #13-01/02
Towers Business Park Century City No.5 Persiaran Pantai Baru No. 8 Jianguomennei Avenue National Library Building
Wilmslow Road Cape Town 59200 Kuala Lumpur Dongcheng District Singapore
Didsbury 7441 Malaysia Beijing 100005 188064
Manchester M20 2EZ South Africa China
United Kingdom
+27 21 830 5242 +60 3 2284 6200 +86 10 6520 4030 +65 6580 4555
+44 (0) 161 438 6200
Monday to Friday Monday to Friday Monday to Friday Monday to Friday
Monday to Friday 08:30 – 17:00 09:00 – 17:00 09:30 – 18:30 09:30 – 17:00
08:30 – 17:00

You might also like