Pseudocode Introduction

Learning to program involves learning not only the syntax and rules of a new language, but also a new way of thinking. Not only do we want to write code that is understandable by the computer, we must also understand what the computer will do when it tries to run that code.

A key part of that is learning to think like a computer thinks. We sometimes call this our “mental model” of a computer. If we have a good “mental model” of a computer, then we can learn to read code and mentally predict what it will do, even without ever running it on an actual computer. This ability is crucial for programmers to develop.

One easy way to develop this ability is to learn how to use a programming language that isn’t an actual programming language. This language cannot (or at least wasn’t intended to) be run on a computer. Instead, we must simply learn to use our “mental model” of a computer to determine what programs written in this language will do.

These languages are sometimes referred to as pseudocode. If we look at the word pseudocode, we see the prefix pseudo, which means “not genuine.” That definition makes sense - a pseudocode is, in essence, not a genuine computer code. So, a pseudocode is simply a programming language that looks like a real programming language, but it isn’t actually intended to be run by a computer.

There are many examples of pseudocode that we could learn. In this course, we’re going to use the pseudocode that is used by the AP Computer Science Principles exam. This is an extraordinarily easy to understand pseudocode, and it covers all of the operations we need to learn in this course. If you want to learn more, you can find the CSP Reference Sheet online by clicking the link.

Throughout this course, we’ll introduce new programming concepts using pseudocode first, which will allow us to learn how they work by adapting our “mental model” of a computer to include the new functionality. By learning how these concepts work in theory first, we’ll be much better able to get them to work in practice on a real computer using Python later. It may sound strange, but this is actually a great way to learn how to program!

In this first lab, we’re going to learn the basics of programming in pseudocode, including how to display message to the user, store information in variables, and write repeatable procedures that we can use as building blocks of a larger program. Let’s get started!