← Back to Articles

Code VS Pseudocode

Jamie Z 2024-02-08

Learning Goals

By the end of this lesson I will be able to:

  • Understand the difference and similarities of Code and Pseudocode
  • Understand how to convert code to pseudocode
  • Understand how to convert pseudocode to code
  • Be familiar with pseudocode conventions

Pseudocode Tips

  • Capitalization: Many programmers use all caps for keywords such as "IF" and "WHILE", and lowercase for variables and function names.
  • Indentation: To indicate the flow of the program, many programmers use indentation to show the structure of the code. For example, statements inside a loop or a function should be indented.
  • Comments: Comments are used to explain the logic of the code and to make it more readable. Comments are usually represented by a pound sign (#) or a double slash (//) at the beginning of a line.
  • Keywords: Pseudocode uses natural language keywords like "IF", "ELSE", "FOR", "WHILE", "PRINT", "RETURN", "FUNCTION" etc.
  • Input/Output: Many programmers use keywords like "INPUT" and "OUTPUT" to indicate when the program is expecting input from the user or displaying output to the user.
  • Variables: Variables are usually represented by meaningful names, and the assignment operator is often represented by the equal sign (=) instead of the colon (:) which is used in Python.
  • Flow Control: The flow of the program is often represented by keywords like "IF", "ELSE", "WHILE", "FOR", "BREAK" and "CONTINUE".

Examples