0% found this document useful (0 votes)
4 views21 pages

Understanding and Editing Pseudocode Algorithms

The document provides an overview of pseudocode as a simplified method for describing algorithms, emphasizing its key features such as sequential structure, input/output operations, and decision-making. It includes examples of algorithms, activities for editing and understanding them, and highlights the debugging process for correcting errors. The key takeaways stress the importance of practicing these skills to enhance computational thinking.

Uploaded by

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

Understanding and Editing Pseudocode Algorithms

The document provides an overview of pseudocode as a simplified method for describing algorithms, emphasizing its key features such as sequential structure, input/output operations, and decision-making. It includes examples of algorithms, activities for editing and understanding them, and highlights the debugging process for correcting errors. The key takeaways stress the importance of practicing these skills to enhance computational thinking.

Uploaded by

joewalct
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

code

Understanding and Editing Pseudocode


Algorithms
IGCSE Computing for Grade 9
Learning Objectives
lightbulb

visibility Follow and understand algorithms presented as pseudocode

search Identify key features of algorithms

edit Edit algorithms to change their functionality

build Correct errors in algorithms


What is Pseudocode?
code

Pseudocode is a simplified, informal way of describing an algorithm that uses the structural conventions of
programming languages but is intended for human reading rather than machine reading.

block Not actual programming code


description Uses plain language with programming structure
visibility Easy to understand and follow
devices Platform independent
Key Features of Pseudocode Algorithms
format_list_bulleted

Sequential structure (steps in order) Input/Output operations


sort input

Variables to store data Decision making (if/then/else)


storage call_split

Repetition (loops) Clear and readable format


loop visibility
Basic Programming Techniques in Pseudocode
code

input 1. Inputs output 2. Outputs storage 3. Variables

Getting data from users Displaying results Storing data for later use

INPUT name OUTPUT result number1 = 10


Example Algorithm 1: Simple Addition
add_circle

code Pseudocode lightbulb Explanation


This algorithm takes two numbers as input, adds them
number1 = input("Enter a number")
together, and outputs the result.
number2 = input("Enter a number")
input Inputs: Two numbers from user
result = number1 + number2
calculate Process: Addition operation
print(result)
output Output: Sum of the numbers
Activity: Following and Understanding Algorithm 1
groups

assignment Instructions notifications Note

help_outline What does this algorithm do?


Be
search What are the key features of this algorithm? share your with the
prepared
observations class.
code What programming techniques are used? to

input Identify the inputs, decisions, and outputs


Editing Algorithms: Changing Operations
edit

arrow_back Before arrow_forward After

number1 = input("Enter a number") number1 = input("Enter a number")

number2 = input("Enter a number") number2 = input("Enter a number")

result = number1 + number2 result = number1 * number2

print(result) print(result)

lightbulb We changed the addition operator (+) to multiplication operator (*) to change the algorithm's functionality.
Example Algorithm 2: Complex Calculations
calculate

code Pseudocode lightbulb Explanation


This algorithm takes two numbers as input, divides the
number1 = input("Enter a number")
first by the second, and outputs the result.
number2 = input("Enter a number")
input Inputs: Two numbers from user
result = number1 / number2
calculate Process: Division operation
print(result)
warning Potential issue: Division by zero
output Output: Quotient of the numbers
Activity: Editing Algorithm 2
edit
assignment Challenge
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
arrow_back Before arrow_forward After

number1 = input("Enter a number") number1 = input("Enter a number")

number2 = input("Enter a number") number2 = input("Enter a number")

result = number1 / number2 result = (number1 - number2) *


number1
print(result)
print(result)
Example Algorithm 3: Working with Outputs
output

code Pseudocode lightbulb Explanation


This algorithm takes a name and age as input, but only
name = input("Enter your name")
outputs a greeting with the name.
age = input("Enter your age")
input Inputs: Name and age
print("Hello ", name)
storage Variables: name, age

error_outline Issue: Age is collected but not used


output Output: Only includes name
Activity: Editing Algorithm 3
edit
assignment Challenge
Change this algorithm so that it outputs the name and age that the user has input in a sentence

arrow_back Before arrow_forward After

name = input("Enter your name") name = input("Enter your name")

age = input("Enter your age") age = input("Enter your age")

print("Hello ", name) print("Hello ", name, " you are ",
age, " years old")
Example Algorithm 4: Selection Statements
call_split

code Pseudocode lightbulb Explanation


This algorithm takes a number as input and checks if it
value = input("Enter a number")
is greater than 10. If it is, it outputs 'Valid'.
if(value > 10):
input Input: A number from user
print("Valid")
call_split Selection: if statement with condition

compare_arrows Condition: value > 10


output Output: "Valid" only if condition is true
Activity: Editing Algorithm 4
edit
filter_1 Challenge 1
Change this algorithm so that it only outputs 'Valid' when the number is greater than 0

arrow_back Before
arrow_forward After

value = input("Enter a number") value = input("Enter a number")


if(value > 10): if(value > 0):
print("Valid") print("Valid")

filter_2 Challenge 2
Change this algorithm so that if the user enters the '+' symbol, the two numbers are added together

arrow_back Before
arrow_forward After

number1 = input("Enter a number") number1 = input("Enter a number")


number2 = input("Enter a number") number2 = input("Enter a number")
symbol = input("Enter the symbol") symbol = input("Enter the symbol")
if(symbol == "*"): if(symbol == "*"):
print(number1 * number2) print(number1 * number2)
elseif(symbol == "+"):
print(number1 + number2)
Example Algorithm 5: Adding Conditions
add_circle_outline

code Pseudocode lightbulb Explanation


This algorithm takes a number as input and checks if it
value = input("Enter a number")
is greater than or equal to 10. If it is, it outputs 'Valid'.
if(value >= 10):
input Input: A number from user
print("Valid")
call_split Selection: if statement with condition

compare_arrows Condition: value >= 10


output Output: "Valid" only if condition is true
Activity: Editing Algorithm 5
edit
assignment Challenge
Change this algorithm so that it also checks if the number entered is less than or equal to 1000

arrow_back Before arrow_forward After

value = input("Enter a number") value = input("Enter a number")

if(value >= 10): if(value >= 10 and value <= 1000):

print("Valid") print("Valid")

tips_and_updates Use logical operator 'and' to combine conditions


Example Algorithm 6: Changing Algorithm Purpose
transform

code Pseudocode lightbulb Explanation


This algorithm initializes x and y to 0, then adds user
x = 0
input values to each.
y = 0
storage Variables: x and y initialized to 0
x = x + input("Enter x value change")
input Inputs: Two values from user
y = y + input("Enter y value change")
calculate Process: Addition to variables
change_circle Next: Change to directional movement
Activity: Editing Algorithm 6
transform
assignment Challenge
Change this algorithm so that it inputs a direction from the user (up, down, left or right). When up is entered, the y value is
increased by 1. When down is entered, the y value is decreased by 1. When right is entered, the x value is increased by 1. When left
is entered, the x value is decreased by 1.

arrow_back Before arrow_forward After

x = 0 x = 0

y = 0 y = 0

x = x + input("Enter x value change") direction = input("Enter up, down,


left or right")
y = y + input("Enter y value change")
if(direction == "up"):

y = y + 1

elseif(direction == "down"):

y = y - 1

elseif(direction == "left"):

x = x - 1

elseif(direction == "right"):

x = x + 1

else

print("Invalid direction")

call_split Selection Logic navigation Direction Control add_circle_outline Increment/Decrement error_outline Error Handling explore
Debugging: Identifying and Correcting Errors
bug_report
error_outline Common Errors in Algorithms build Debugging Process

psychology Logical Errors 1 Identify the problem


Algorithm works but produces wrong results

2 Locate where the error occurs


code Syntax Errors
Incorrect pseudocode structure

3 Determine the cause

play_circle_outline Runtime Errors


Problems during execution
4 Fix the error

5 Test the corrected algorithm


Summary and Key Takeaways
summarize
lightbulb Key Takeaways

description Pseudocode is a simplified way to describe algorithms using programming structure

format_list_bulleted Key features include inputs, outputs, variables, and decision making

edit Editing algorithms involves changing operations, outputs, conditions, and even the
help_outline
entire purpose
Questions?
bug_report Debugging is a systematic process of identifying and correcting errors

psychology Practice following, understanding, editing, and correcting algorithms to build your
computational thinking skills

You might also like