Can you place block A next to block B?
Key Definition – Pseudocode
Pseudo-code is …
Pseudocode can look similar to code but it does not need to follow the rules of a particular language.
…used to develop algorithms before coding
This means you can develop algorithms quickly without worrying whether your script will work with a particular programming language.
…easily converted in to a number of different languages.
Rules – What Rules?!?
There are no set rules for writing pseudocode, but you will often see the following:
- INPUT – indicates a user will be inputting something
- OUTPUT – indicates that an output will appear on the screen
- WHILE – a loop (iteration that has a condition at the beginning)
- FOR – a counting loop (iteration)
- REPEAT – UNTIL – a loop (iteration) that has a condition at the end
- IF – THEN – ELSE – a decision (selection) in which a choice is made
- any instructions that occur inside a selection or iteration are usually indented
Challenge 1 – Double the number
Write a pseudo-code algorithm that asks the user for a number, doubles and then displays the number.
Challenge 2 – Calculate the area of a circle
Write a pseudo-code algorithm that asks the user for the radius of a circle and then displays the area of the circle.
Challenge 3 – Calculate the circumference of a rectangle.
Write a pseudo-code algorithm that asks the user for the length and width of a rectangle and then displays the circumference of the rectangle.
Completed the starter activity?
Completed each of the challenges?
Completed the learning log?
Written your homework on your planner?