# 3.5: Pseudocode and Flowchart Conventions

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$

( \newcommand{\kernel}{\mathrm{null}\,}\) $$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\id}{\mathrm{id}}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\kernel}{\mathrm{null}\,}$$

$$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$

$$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$

$$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

$$\newcommand{\vectorA}[1]{\vec{#1}} % arrow$$

$$\newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow$$

$$\newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vectorC}[1]{\textbf{#1}}$$

$$\newcommand{\vectorD}[1]{\overrightarrow{#1}}$$

$$\newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}}$$

$$\newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}}$$

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

## Pseudocode

Pseudocode is an informal way of representing the steps a computer program performs before it is coded into the syntax of any specific programming language. The first step in programming is to break a task into steps a computer can perform and a flow chart is a good way to do this.  Now for very complicated programs a flowchart may not be tenable, and you may need to break some steps that are often repeated into a function that can be called to perform the repeating processes.  So you may want to break your complex program into smaller ones (functions) that are sequentially called and iteratively develop these one at a time. The order by which a program performs the sequential steps is important and this order can be described with a flowchart.

## FlowCharts

Flowcharts are a good way to present pseudocode as they break the task into individual steps and show the order in which they may need to be processed. In a flowchart certain symbols are used to represent the types of individual tasks a computer can perform and we will use the International Standards Organization (ISO) ISO 5807 standards developed by the American National Standards Institute (ANSI) in 1985 (Wikipedia:Flowcharts). Although you can draw these by hand or in a program like Excel or Word, you will be required to develop these using the diagrams.net/draw.io software integrated into your Google Drive as you will also be using that software later this semester when we create electric circuit diagrams, as described in section 1.1.2 Programming and Flowcharts of the web resources section of the general resources of the IOST library.ISO

### Flowchart with conditional statement

We want to make a small program that checks the input for the molar mass of a molecule and determines if it is valid.  Since hydrogen is the smallest molecule, the molar mass can not be less than H2, or 2 g/mol, and we want to reject any data that is smaller.  The left flowchart uses the less than (<) comparison operator with an if-statement to create a condition statement that checks to see if the user input has an invalid molar mass (<than 2 g/mol) and print out a warning if it does. This takes advantage of the Boolean data type that is output from the if statement and has one of two values; true or false. The coding syntax in python for this statement is covered in section 5.9.2: if-statements.  Note, a better way to do this would be to switch the comparison operator to greater than or equal (>=) and use an if-else condition, where it prints the molar mass if it is greater than 2 g/mol (True) and requests for a new molar mass that is greater than 2 g/mol if the original input was less than 2/g/mol.  This example with python code is covered in the section 5.9.3: else-if statement

The first assignment is based on the aquarium in figure $$\PageIndex{2}$$ that is the home to some Mystery Snails. Your instructions will be posted to the class assignment page and you need to create a flowchart with diagrams.net that maintains the temperature in a safe range during the winter months by turning on a heater if the temperature is too low and turning it off if it is too high. You can identify the safe temperature range in this article on a Care Guide for Mystery Snails by the aquarium coop. In this assignment you will need to read the temperature, and then run an if-statement or two. In an if-statement you use a boolean True/False logic based on the condition you set. You do not need to worry about syntax in this activity as we are not writing code, just creating the flowchart, but you may want to search the web and if you find something you like, annotate it with Hypothes.is and tag it with a tag like [if-statement] (without the brackets). But one of the goals of this course is for you to develop the skills to find code and resources on the web, and you should start now.

3.5: Pseudocode and Flowchart Conventions is shared under a not declared license and was authored, remixed, and/or curated by LibreTexts.