Page 269 - AI Ver 1.0 Class 9
P. 269
Display "Award given"
Otherwise
Display "No award"
2. Go up again till number of repeat is less than or equal to 10
Algorithm
An algorithm is a step-by-step approach to identify and solve a problem in a finite time. It is used in a problem-
solving phase of any programming task and helps in defining the clear instructions in sequence. An algorithm uses
simple English-like statements to represent the steps of a program. There may be more than one way to solve any
problem, so there may be more than one algorithm for a given problem. It must terminate after a finite number
of steps. Once we have an algorithm, we can translate it into a computer program in any programming language.
Brainy Fact
The word 'algorithm' come from the name of a Persian mathematician called Al-Khwārizmī.
Writing an Algorithm
Let us do an activity of writing an algorithm for making cucumber and tomato sandwich:
Step 1 Take a few slices of tomato and a cucumber.
Step 2 Take two slices of multigrain bread.
Step 3 Put tomato sauce on one slice.
Step 4 Put cheese spread on another slice.
Step 5 Place a few slices of tomato and cucumber between the two slices of bread.
Step 6 Cut it into two halves and serve it.
Advantages of an Algorithm
Advantages of an algorithm are as follows:
• It is a step-by-step representation of a solution to a given problem.
• It uses simple English-like statements so it is easy to understand and write.
• The problem is broken down into smaller pieces, hence it is easy to convert it into a program using any
programming language.
Disadvantages of an Algorithm
Disadvantages of an algorithm are as follows:
• Since there is no standard rule for writing an algorithm, it varies drastically.
• It is a time-consuming process.
• It is difficult to represent branching and looping in an algorithm.
Introduction to Python 267

