Skip to content

Advanced Programming I – SS3 Digital Technologies Lesson Note (First Term)

Download this term · ₦1,000

Lesson note at a glance

Subject
Digital Technologies
Class
SS3
Term
First Term
Topic
Advanced Programming I
Order
Topic 1 of 7 this term
Reading time
4 min

A function is a named block of code that performs a specific task. An array, called a list in Python, is one object that holds many items in a specific order. Functions let us write code once and reuse it, while arrays let us keep many values together. The two are often combined.

Advertisement

Behavioural objectives

By the end of the lesson, students should be able to:

  • Define a function and give two reasons for using one.
  • Identify the parameters, body and return value of a function.
  • Explain what an array is, and describe elements and indices.
  • Describe four common array operations: accessing, appending, inserting and traversing.
  • Explain how a function can take an array as its input.

What is a function?

Imagine you are a chef. Every time a customer orders a “Special Omelette,” you have to:

  1. Crack three eggs.
  2. Chop onions and peppers.
  3. Whisk with salt.
  4. Fry for 3 minutes.

If you have 50 customers, explaining those four steps 50 times is exhausting and leads to mistakes. Instead, you write the recipe once and label it “MakeSpecialOmelette.” Whenever you need it, you call that name.

In programming, a function is exactly that: a named block of code that performs a specific task. We use functions for two main reasons:

  • Reusability: Write once, use a thousand times.
  • Organisation: It keeps our main code from looking like a messy “spaghetti” bowl.

How do functions work?

A function is like a small machine. You put something in, it does some work, and it gives something back.

  1. Parameters (the inputs): These are the “ingredients” the function needs. For a calculator, the inputs would be two numbers.
  2. The body (the process): This is the logic. It is where the addition, subtraction or sorting happens.
  3. Return value (the output): This is the final result sent back to the main program.

Example in simple code (Python)

def greet_student(name):
return “Hello ” + name + “, welcome to SS3!”

In this case, name is the input, and the greeting is what the function “returns” to us.

What is an array?

Up to now, we have used variables to store information. A variable is like a single box that holds one item. If you have a list of 100 students, creating 100 separate variables (student1, student2, and so on) is slow and easy to get wrong.

Advertisement

This is where arrays (or lists in languages like Python) come in. An array is like a bookshelf. It is one single object that holds many items in a specific order.

Key rules of arrays

  • Elements: The actual items inside the array.
  • Index: The “address” or position of the item.
  • The zero rule: In programming, we almost always start counting at 0, not 1. So, the first item is at index 0.

What are the common operations on arrays?

Once you have your “bookshelf” (array), you need to know how to handle the books. There are four main operations:

  1. Accessing: Looking up what is at a specific position (for example, “What is at index 2?”).
  2. Appending: Adding a new item to the very end of the list.
  3. Inserting: Putting an item into the middle, which pushes everything after it back.
  4. Traversing: Walking through the list from start to finish to check every item.

The loop connection

Arrays and loops are used together. If you want to give every student in an array an “A” grade, you use a for loop to step through each index one by one.

How are functions and arrays used together?

We often write functions that take an entire array as an input.

Scenario: You have an array of 10 exam scores and you want to find the average.

  • The function: calculate_average(scores_list)
  • Inside the function: It adds all the numbers in the array together and divides by the total count.
  • The result: It returns a single number (the average).

Key points to remember

  • Functions save time by grouping logic.
  • Arrays save space by grouping data.
  • Indices usually start at 0.

Clean code means using descriptive names so anyone can read your work.

Evaluation

  1. What is a function? Give two reasons for using one.
  2. Name the three parts of a function and say what each one does.
  3. What is an array, and at which index is the first item?
  4. Explain the difference between appending and inserting.
  5. Describe how calculate_average(scores_list) finds the average of 10 exam scores.

Assignment

  1. Choose a task you repeat often, such as making a meal. Give it a function name, then state its inputs, what happens in its body and what it returns.
  2. Explain traversing an array, and say how a for loop can be used to give every student in an array an “A” grade.

This term's Digital Technologies topics

SS3 First Term · 7 topics

  1. Advanced Programming I
  2. Advanced Programming II
  3. Software Development Lifecycle
  4. Networking II
  5. Cloud and Virtualization
  6. Internet of Things (IoT) Application
  7. Data Protection and Backup System
Downloads

Get Digital Technologies as PDF and Word

Every week of SS3 Digital Technologies, First Term, formatted and ready to print. Ad-free, and the copy lock comes off.

Get this term Card, bank transfer, USSD or OPay

Advertisement

Lesson Notes for Other Classes

Print it or edit it in Word

Every note is free to read online. A PDF or Word copy of one subject costs ₦1,000 for one term, or ₦2,000 for all three terms.

Continue with GoogleContinue with Facebook

Sign in first, then choose your class and subject at checkout.