0% found this document useful (0 votes)
20 views23 pages

Algorithms and Data

Uploaded by

shidaalartey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views23 pages

Algorithms and Data

Uploaded by

shidaalartey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Algorithms and data

Follow, understand, edit and correct algorithms that are presented as


pseudocode.
 An algorithm is a step-by-step set of
What Is an instructions used to solve a problem or perform

Algorithm? a task. It’s like a recipe in cooking—each step


leads you closer to the final result.
 Pseudocode is a simplified, structured way of
writing algorithms using plain English mixed with
What Is programming-like syntax. It’s not meant to run on

Pseudocod a computer—it’s meant to help humans


understand the logic of a program.
e?  Think of it as the blueprint of a program before
you build it in a real programming language.
 1. Boil water
 2. Place tea bag in cup
Here’s a  3. Pour hot water into cup
simple  4. Wait 3 minutes
algorithm  5. Remove tea bag

for making  6. Add sugar or milk if desired

tea:  7. Stir and serve


 INPUT num1
 INPUT num2
 IF num1 > num2 THEN
 OUTPUT num1
Examples 1  ELSE
 OUTPUT num2
 ENDIF
 number1 = input("Enter a number")
 number2 = input("Enter a number")

Examples 2  result = number1 + number2


 print(result)
 number1 = input("Enter a number")
 number2 = input("Enter a number")
Answer  result = number1 * number2
 print(result)
 Change this algorithm so that it subtracts the
second input from the first, then multiplies this
new value by the first input and outputs this value
 number1 = input("Enter a number")

Examples 3  number2 = input("Enter a number")


 result = number1 / number2
 print(result)
 number1 = input("Enter a number")
 number2 = input("Enter a number")

Answer  result = (number1 - number2) * number1


 print(result)
Key  Clear: Each step must be understandable

Features  Finite: It must end after a certain number of steps

of an  Effective: It should solve the problem correctly

Algorithm  Ordered: Steps must be in the right sequence


 INPUT name
 INPUT favouriteColour
 INPUT favouriteFood
 OUTPUT "Hello ", name, " your
What will be
favourite food is ",
the output
favouriteFood, " and your
favourite colour is ",
favouriteColour
 What is pseudocode?
 When is pseudocode
used?
 Why is pseudocode
used?
 What features does
pseudocode contain?
 Answer: A form of representing
an algorithm without a set
syntax.
 Answer: When planning or
designing algorithms.
 Answer: It is language
Answer independent so anyone should
be able to understand it.
 Answer: Command words,
assignment symbols,
mathematical symbols.
Follow flowcharts and pseudocode algorithms that use conditional statements
What are the key
words used in
conditional
statements in
IF, THEN, ELSE
programming?
What are the
different symbols
>, <, >=, <=,
that can be used
for comparisons? <> =
Flowchart
What will be
the output
when 10 is
the input?
if condition:
 Code to run if
true
If statement else:
 Code to run if
false
endif

 IF condition THEN
 Code to run if true
 ELSE
 Code to run if false
 ENDIF
 or

If statement  If (condition)
 Then
 Code to run if true
 Else
 Code to run if false
 endif
 Input Value1
 Input Value2
 if Value1 >= Value2:
 OUTPUT Value1
 else:
 OUTPUT Value2

 Colour = INPUT("Do you prefer purple or
green?")
 if Colour == "purple":
 OUTPUT "Purple is the best"
 else:
 OUTPUT "Purple is better than green"
Predict the outcome of
algorithms and test that they
meet those outcomes.

You might also like