What is Pseudocode?

by Angie Kalthoff and Pati Ruiz

Welcome back! As many of us head back to school, we wanted to share our thoughts on Pseudocode and making coffee is one example we thought would be appropriate. Think of pseudocode as a way to help you organize your thoughts in a sequential manner as you design your project, before you translate it to code. Pseudocode is written in a form that is similar to the language you speak, and allows you think through how to solve a problem without having to worry about the rigorous syntax of a programming language.

In fact, pseudocode is simple enough that you don’t need a background in computer science (CS) to write or read it. Pseudocode is can be translated into a programming language and is a great way to help you organize your thoughts. Students might write pseudocode for non-programming or “unplugged” activities, or as they prepare to write programs in block languages or more advanced programming languages.

You may be wondering: Why not just use code to write the program? Syntax. When writing in pseudocode, you are taking your thoughts and transcribing them into a language you understand and can communicate to others. You are in control of the structure and don’t have to worry about choosing a specific programming language or worry about syntax errors (which mean that your code does not work!). The goal of pseudocode is to describe the code of your program in a relaxed way – without worrying too much about the details. And, while pseudocode is written in “english-like” language, more experienced programmers (also known as developers) tend to write pseudocode that is more similar to the syntax of the target programming language.

Sometimes, using images or flowcharts also help as you design your project. A flowchart often starts with a question that has two possible answers:

  • yes/no
  • true/false

Flowcharts use special shapes to represent steps, decisions, or actions, and lines between shapes  to show the flow or sequence between the steps. Shapes used include ovals (for start and end), diamonds (for questions/decisions), rectangles (for processes), and other actions. Additional shapes could also be used – it’s up to you! To learn more about flowcharts, visit Pseudocode and Flowcharts.

Classroom use of Pseudocode

Many lessons have been developed to help you and your students think sequentially about everyday tasks. By starting in early grades, students will have practice developing their “computational discourse skills”. Computational discourse skills are described by Grover and Pea (2013) as ones that help children develop a vocabulary that is faithful to the computer science discipline while also allowing for the development of an understanding of programming and computational thinking concepts and skills.

Classroom connections to pseudocode include tasks your students have to complete and the directions they need to follow to accomplish these tasks. When students wash their hands, there are a series of steps that are taken. You can think of these as the directions for handwashing or as an algorithm (a list of steps that you can follow to finish a task). To write these steps, we break them down into understandable chunks, and write them in a sequential order.

If someone has never washed their hands before, you could not simply say “wash your hands.” Instead you could write it out in pseudocode.

Wash your hands.
    Walk to a sink.
    Turn on the water.
    Pump the soap dispenser as many times as necessary with one 
    hand while holding your second hand below it in order for the 
    soap to fall into that hand. 
    Stop pumping when a quarter sized amount of soap is in the  
    second hand.
    Once soap is in hand, rub hands together to distribute soap     
    between hands.
    Place hands under running water while rubbing them together.
    Rub hands until so is no longer present.
    Turn off water.
    Pick up towel and rub on hands until hands are dry.

Here are a few example lessons that you could start using in your K-5 classrooms to build students’ computational discourse skills::

In addition to the unplugged activities shared above, students in grades 6-12 can begin developing a pseudocode practice as a precursor to writing code. This Bubble Sort Unplugged Activity is an excellent example of what older students should be able to do with pseudocode. Another example is this Python ‘elif’ exercise found on usingpython.com. Professional programmers all have their own pseudocode styles – some like less detail and some prefer more detail. Some developers use a different method altogether during their software development process.

Want to know what pseudocode could look like? Visit Gabriel Comeau’s post to see how he describes how to make coffee using pseudocode.

Resources

Works Cited:

Grover, S., & Pea, R. (2013). Using a discourse-intensive pedagogy and android’s app inventor for introducing computational concepts to middle school students. In Proceeding of the 44th ACM technical symposium on Computer science education (pp. 723-728). ACM.

How to cite this work

CIRCL Educator posts are licensed under a Creative Commons Attribution 4.0 International License. If you use content from this site, please cite the post and consider adding: "Used under a Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/)."

Suggested citation format: [Authors] ([Year]). [Title]. CIRCLEducators Blog. Retrieved from [URL]