{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Lesson 1c: Conditionals\n", "\n", "**Conditionals** are used to tell your computer to do a set of instructions depending on whether or not a Boolean is `True`. In other words, we are telling the computer:\n", "\n", " if something is true:\n", " do task a\n", " otherwise:\n", " do task b\n", "\n", "In fact, the syntax in Python is almost exactly the same. As an example, let's ask whether or not a codon is the canonical start codon (`AUG`)." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This codon is the start codon.\n" ] } ], "source": [ "codon = 'AUG'\n", "\n", "if codon == 'AUG':\n", " print('This codon is the start codon.')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The syntax of the `if` statement is apparent in the above example. The Boolean expression, `codon == 'AUG'`, is called the **condition**. If it is `True`, the indented statement below it is executed. This brings up a very important aspect of Python syntax.\n", "\n", "