> For the complete documentation index, see [llms.txt](https://igb.mit.edu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://igb.mit.edu/mini-courses/python/introduction-to-python-for-biologists/control-flow.md).

# Control Flow

<figure><img src="https://498238201-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWuHhstIreJ3jFvE4gQ3y%2Fuploads%2FT4mICK9MBxoh9hjwfvm6%2FIF_ELSE.png?alt=media&amp;token=47edb6f0-2bca-48c3-86a6-e7d195815873" alt=""><figcaption><p>If_else determines the logic flow of the program</p></figcaption></figure>

* The structure of the if-else statement has the form:

```
if (condition1 is true):
  do A
elif (condition2 is true):
  do B
else:
  do C
```

* example 1: grading test scores

```
In [1]: grade=None

In [2]: score=86

In [3]: if (score>93):
   ...:     grade='A'
   ...: elif (score>85):
   ...:     grade='B'
   ...: else:
            grade='C'    

In [4]: grade
Out[4]: 'B'

```

* example 2: palindrome

```
In [8]: seq1="ACTCA"

In [9]: if seq1==seq1[::-1]:
   ...:     print("%s is a palindrome!" % seq1)
   ...:     
ACTCA is a palindrome!
```
