Pseudocode means ‘mock’ or ‘pretend’ code and that it is way of describing/writing a program without using a specific programming language.
Pseudocode uses control structures and keywords similar to those found in programming languages.
Example of psedocode is:
SET name TO ‘dude’
How would this look in Python?
You need to be able to understand and use pseudocode but not write programs using it.
Python code example:
for a in range(0, 10):
The pseudocode for the above code is
FOR a FROM 0 TO 10
SEND 0 to 10 TO DISPLAY
hunger is set to N
WHILE hunger does not = Y DO
RECEIVE hunger FROM (STRING) KEYBOARD and SEND ‘Are you hungry yet’ TO DISPLAY
SEND ‘So eat!’ TO DISPLAY
hunger = "N"
while hunger != "Y":
hunger = input("Are you hungry yet??")
What does this pseudocode do?
RECEIVE myName FROM (STRING) KEYBOARD
RECEIVE myAge FROM (INTEGER) KEYBOARD
SET AgeInTen TOmyAge + 10
SEND myName “will be” AgeInTen “in 10 years’ time” TO DISPLAY
Write the Python code for this program.
Past exam paper
Below is a question from a past edexcel exam paper. The question is some pseudocode with a 5 mark question at the end. Try coding the question in Python to help you understand both psedocode and the Python code needed to code it.