TimesEdu
NotesLower SecondaryDigital Literacyfunctions and procedures 30058
Back to Digital Literacy Notes

Functions and procedures - English B2 (Upper Intermediate) English A1-C2 Study Notes

Functions and procedures - English B2 (Upper Intermediate) English A1-C2 Study Notes | Times Edu
Lower SecondaryDigital Literacy~7 min read

Overview

Imagine you're building with LEGOs. Instead of building every single brick from scratch each time you need a window or a door, wouldn't it be great if you had pre-made window and door pieces you could just snap in? That's exactly what **functions** and **procedures** do in programming! They are like mini-programs or recipes that tell the computer to do a specific job. This makes your main program much tidier, easier to understand, and quicker to build because you don't have to write the same instructions over and over again. Learning about functions and procedures is super important because almost all computer programs, from your favorite video games to the apps on your phone, use them to stay organized and work efficiently. They help programmers build big, complex things out of smaller, manageable pieces.

What Is This? (The Simple Version)

Think of functions and procedures (sometimes called subroutines or methods) like a special instruction card or a mini-robot that knows how to do one specific task really well. Instead of you, the main chef (your program), doing everything yourself, you can just ask this mini-robot to do its job.

  • Functions: These are like a mini-robot that does a job AND gives you something back when it's finished. For example, a robot that calculates the total cost of your shopping list and then tells you the answer.
  • Procedures: These are like a mini-robot that does a job but doesn't necessarily give you anything back directly. It just does its task. For example, a robot that cleans your room โ€“ it does the cleaning, but it doesn't hand you a 'clean room' report.

They help keep your main program (your big recipe book) neat and tidy. Instead of writing the same steps for 'make a sandwich' every time you want one, you just write 'make a sandwich' once, and then you can call upon that instruction whenever you need it.

Real-World Example

Let's imagine you're making a big, fancy birthday cake with lots of decorations. This whole process is your main program.

  1. Making the Cake Batter (Procedure): You have a recipe for 'Make Vanilla Cake Batter'. You follow the steps: mix flour, sugar, eggs, milk. This is a procedure because it does a job (makes batter) but doesn't hand you a specific 'result' number. It just changes the state of things (now you have batter instead of separate ingredients).
  2. Calculating Frosting Needed (Function): You need to know how much frosting to make. You have a recipe for 'Calculate Frosting Amount'. You tell it how many layers your cake has, and it tells you back a number โ€“ 'you need 3 cups of frosting'. This is a function because it takes information (layers) and gives you a specific answer (3 cups).
  3. Decorating the Cake (Procedure): You have a set of instructions for 'Decorate Cake with Sprinkles'. You follow them: sprinkle, sprinkle, sprinkle. This is another procedure; it performs an action but doesn't return a value.

See? You break down the big task (making a cake) into smaller, manageable, reusable mini-tasks.

How It Works (Step by Step)

Imagine you're giving instructions to a friend to help you with a task. Here's how functions and procedures work: 1. **Define It:** First, you write down the specific steps for your mini-task. This is like writing the recipe for 'Make Vanilla Cake Batter'. 2. **Give It a Name:** You give this set...

Unlock 3 More Sections

Sign up free to access the complete notes, key concepts, and exam tips for this topic.

No credit card required ยท Free forever

Key Concepts

  • Function: A named block of code that performs a specific task and usually returns a value.
  • Procedure: A named block of code that performs a specific task but does not necessarily return a value.
  • Call: To execute or run a function or procedure by referring to its name.
  • Argument/Parameter: Information or data that you pass into a function or procedure for it to use.
  • +4 more (sign up to view)

Exam Tips

  • โ†’Clearly understand the difference between a function (returns a value) and a procedure (performs an action).
  • โ†’Practice identifying arguments/parameters and return values in example code snippets.
  • +3 more tips (sign up)

AI Tutor

Get instant AI-powered explanations for any concept in this topic.

Still Struggling?

Get 1-on-1 help from an expert Lower Secondary tutor.

More Digital Literacy Notes