PYTHON Key stage IV Class IX
Keys Concepts # 1
ALGORITHM
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Concept Overview
Coding Concept Sub - Concepts
● Definition of algorithm
● Characteristics of an algorithm
Algorithm ● Examples of algorithm
● Design algorithm for simplifying problems
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Objectives
● Define algorithm with examples.
● Explain the characteristics of an algorithm.
● Write an algorithm for a given problem.
● Explain the benefits of using algorithms to solve a problem.
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
ACTIVITIES
1. Understanding Algorithm
2. Demo 1 - Brushing your teeth
3. Activity 1 - Writing Algorithm
4. Demo 2 - Adding two numbers
5. Activity 2 - Multiplying two numbers
ALGORITHM 6. Activity 3 - Area of circle
7. Activity 4 - Perimeter of rectangle
8. Activity 5 - Eligibility for voting
9. Activity 6 - Even or odd Number
10. Activity 7 - Check Your Understanding
11. Activity 8 - Importance of learning algorithm
12. Activity 9 - Practice Questions
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Algorithm
An algorithm is a step-by-step set of instructions for performing a task.
Step Algorithm
1 START Inputs
2 Read first number
3 Read second number
Process
4 Add first and second number
5 Display the sum
Output
6 STOP/End
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Algorithm (cont.)
For an algorithm, you need to have the following:
1. Input 2. Process 3. Output
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Demo 1 - Brushing Your Teeth
Step Algorithm
1 START
2 Walk to a bathroom.
3 Put toothpaste on the toothbrush.
4 Brush your teeth.
5 Rinse your mouth and toothbrush.
6 Put the toothbrush away.
7 STOP/End
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Activity 1 - Writing Algorithm
1. Divide yourselves into four groups.
2. Each group will receive a topic and in respective groups
discuss the steps.
3. Write an algorithm for the problem in your notebook.
4. Then share the algorithm to the class.
1 2 C
3 4
Crossing a road Preparing suja Cooking ema-datshi Washing hands
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Activity 1 - Solution
1 2
Algorithm for Crossing a Algorithm for Preparing suja
road
1. Add suja tea leaves and water
1. Walk to an edge of a road. in a pot.
2. Look right and left for a 2. Boil for 15 minutes.
vehicle.
3. Takeout the tea leaves.
3. Wait if there is a vehicle.
4. Add salt and butter.
4. Cross the road once it is safe.
5. Mix with a machine.
5. Reach the other side.
6. Ready to drink.
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Activity 1 - Solution (cont.)
3 4
Algorithm for Preparing Algorithm for Washing hands
ema-datshi 1. Wet hands and apply soap.
1. Wash the chillies, onions 2. Rub the palms together.
and tomatoes. 3. Rub the back of hands.
2. Chop and put in a pot. 4. Rub the back of the fingers.
3. Add oil, salt and cheese. 5. Rub and clean the thumbs.
4. Cook for 20 minutes. 6. Rub and clean the tips of the
5. Stir for few seconds. fingers.
6. Ready to eat. 7. Rinse the hands.
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Importance of Algorithm
1 5
3
To provide
To find a solution for To understand a straightforward
the problem. the core idea behind explanation of how it
2 4 works without
a problem.
getting into too
To break down a technical.
To understand the complex problem
flow of the problem. into smaller and
more manageable
steps.
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Characteristics of Algorithm
Watch the video to understand the characteristics of algorithm
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Characteristics of Algorithm
Unambiguous
Independent
Algorithm steps
Algorithm must should be clear and
be applicable to straightforward.
any language.
Characteristics
Feasibility Input
of
Algorithm should Algorithm Algorithm should
be feasible. have 0 or more
inputs.
Finiteness Output
Algorithm should Algorithm should have
terminate after certain have at least one output.
number of steps.
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Demo 2 - Finding Average of Two Numbers
Solution
Step Algorithm
Write an algorithm to find 1 START.
the average of any two
2 Read any two numbers(x and y).
numbers entered by the
user and display the result. 3 Average = (x+y)/2.
4 Display Average.
5 STOP/End.
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Activity 2 - Multiplying Two Numbers
Solution
Step Algorithm
Write an algorithm to 1 START.
multiply any two
numbers and display 2 Take input for x and y.
the result. 3 Multiply = x * y.
4 Display Multiply.
5 STOP.
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Activity 3 - Area of Circle
Solution
Step Algorithm
Write an algorithm in your
1 START.
notebook to find the area
of a circle when a user 2 Read a radius of a circle (r).
enters a radius from the
3 area = 3.14*r*r.
keyboard and display the
area. 4 Display area.
5 STOP.
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Activity 4 - Perimeter of Rectangle
Solution
Step Algorithm
Write an algorithm in
1 START.
your notebook to find
the perimeter of a 2 Read a length and width (l, w).
rectangle and display
perimeter = 2*(l+w) or
the perimeter. 3
perimeter = l+w+l+w.
4 Display perimeter.
5 STOP.
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Activity 5 - Eligibility for voting
Solution
Write an algorithm in your
notebook to check whether a Step Algorithm
person is eligible to cast a vote 1 START.
using the following criteria:
2 Read the age.
1. If the age is 18 and above,
3 Check if age>= 18, then got to step 4
then display a message
‘Eligible to vote’ 4 Display ‘Eligible to vote’.
2. Otherwise display a 5 Otherwise, display ‘Not eligible to vote’.
message, ‘Not eligible to
6 STOP.
vote.’
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Activity 6 - Even or Odd number Solution
Step Algorithm
Arrange the given algorithm in correct
order to check whether the number is 1 START.
even or odd.
2 Read the number(num).
1. R=num%2
3 R=num%2.
2. Display ‘Number is Even’
3. START 4 If R is equal to zero.
4. Display ‘Number is Odd’
5 Display ‘Number is Even’.
5. STOP
6. If R is equal to zero 6 Otherwise
7. Read the number(num) Display ‘Number is Odd’.
7
8 STOP.
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Activity 7 - Check your understanding
Mention and explain the characteristics of an algorithm.
1 2 3
Unambiguous Input Finiteness
Algorithm steps should be Algorithm may or may not Algorithm should
clear and straightforward. take input. terminate after certain
number of steps.
4 5 6
Independent Feasibility Output
Algorithm must be Algorithm should be Algorithm should have
applicable to any feasible. have at least one output.
language.
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Activity 8 - Importance of learning algorithm
List any three importance of learning algorithm.
To understand the core idea behind a problem.
To understand the flow of the problem.
To break down a complex problem.
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Practice 1 - Greatest Number
Solution
Step Algorithm
1 START
Write an algorithm to find 2 Read any two numbers a, b
the greatest of two
3 Check if a>b, then go to step 4
numbers.
4 Display “a is greater than b”
5 Otherwise, Display “b is greater than a”
6 STOP
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Practice 2 - Pass or Fail
Solution
Step Algorithm
Write an algorithm that prompts
1 START
the user to input their exam
2 Enter a mark [m]
marks and determines whether
3 Check if m>=40, then go to step 4
they have passed or failed. The
4 Display ”Passed”
pass mark is 40 out of 100.
5 Otherwise, Display “Failed”
6 STOP
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Key
Points
● An algorithm is step-by-step solution for a specific problem.
● In algorithm you need to have input, process and output.
● Algorithm is used to understand the flow of the problem.
● Algorithm helps to break down a complex problem into smaller and more
manageable steps.
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
Key Points (Cont.)
● Characteristics of algorithms are:
○ Unambiguous : steps should be clear.
○ Inputs : it may or may not take input.
○ Output : should produce at least one output.
○ Finite : should have limited number of steps.
○ Feasibility : should be feasible.
○ Independent : must be applicable to any languages.
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class IX
བཀྲིན་ཆེ།
THANK YOU
January 2024 © ICT Curriculum, MoESD