Subroutine
s
10/11/202
4You are trying to complete a set of research
assignments.
Which room is better equipped to help
you
Extension – Explain why?
Title: Subroutine – Functions & Procedures 10/11/2024 VALUES
ATTITU
DES
Literacy Key Words ATTRIB
Lesson objective: To understand that Subroutine, UTES
Functions,
code can be simplified using subroutines Procedures,
Arguments
During this term, you will be looking at
SUCCESS CRITERIA - Depth of
python. Understanding
Check your understanding by asking
yourself the following each lesson: I do not know what a
Subroutines
Identify what is a function
Describe what is a ADVANCED
procedure I have a slight Identify what
is a function
COGNITIVE
PERFORMA
NCE
Explain the difference
between the two
5
I could accurately describe
what is procedure
Create a program code
using functions and
procedures G I can Explain the difference
r between a function &
a Procedure
d
e
I can Create a program
code to create a function
with a procedure
Objectives and Outcomes
Create a program code to perform a
function stating the procedure with an
Stre argument
tch Evaluate the difference between a
function and a procedure
Challe
nge Identify what is a function in python
Expec
I do not know what a Subroutines
ted
KEYWORDS: Python, programming, Data Types, Operators,
Import, Arithmetic
االستيراد، عوامل التشغيل، أنواع البيانات، البرمجة، بايثون:الكلمات الرئيسية
الحساب، 키워드 : Python, 키
Activate – This is where you absorb information
What is a Why do we
Procedure use a
Procedure
A procedure we use procedures to
can be better organise our
thought of as code so that finding
a mini errors and editing the
program or a code can become
subroutine. easier.
It sits in the This is because major
background sections of our code is
waiting to be self-contained and
called. separate from one
another
Activate – This is where you absorb information
Procedure Vs
functions
PLEASE NOTE: A procedure performs a
task, whereas a function produces
information.
Functions differ from procedures in that functions return
values, unlike procedures which do not.
However, parameters can be passed to both
procedures and functions.
Activate – This is where you absorb information
Setting up a
procedure
Procedures sit at the top of our code.
The are declared using the ‘def’ command.
They are then given a name.
E.G.:
def procedure1(): Notice the
brackets and
The code for the procedure is then written
‘indented’ underneath. colon!
‘def’ means to define (define a function (aka
method))
Activate – This is where you absorb information
Example of a
procedure function
procedure
Lesson Objectives
Identify what are libraries in python
Evaluate the difference between a function and a procedure
Create a program code that will use arithmetic methods
Activate – This is where you absorb information
Practice- Here is a model example
Lesson Objectives
Identify what are libraries in python
Evaluate the difference between a function and a procedure
Create a program code that will use arithmetic methods
Demonstrate – This is where you apply and embed your knowledge
Expect
Create a subroutine that ask the user for their
name and then display their name with a
greeting.
Challenge
Define a subprogram that will ask the user to
enter a number and save it as the variable
“num”. Define another subprogram that will
use “num” and count from 1 to that number
Demonstrate – This is where you apply and embed your knowledge
Stretch
Create a program that will create 3
procedures. The first procedure must allow
the user to input a low number and a high
number, it will then store a computer number
which is a random number between the two
inputted values.
Your second procedure must display a
message saying “I am thinking of a number
between” low and high and allow the user to
input a guess.
Third procedure is to check if the guess is
correct, if the guess is too low or too high a
prompt must be given to the user with the
option od guessing again.
Demonstrate – This is where you apply and embed your knowledge
Stretch
Plenary – Reflecting upon and reinforcing new learning
Define or give an example for the three words: