Conditionals

Concepts

  • Boolean type: bool

  • Relational and logic operadors

  • condition (or boolean expression)

  • conditional statement: simple and multiple

  • sequencial and nested conditional statements

  • pass statement

Keywords

True, False,
=, ==, <, <=, >, >=, !=,
not, and, or,
if <condition>:
  ...
else:
  ...
if <condition>:
  ...
elif <condition>:
  ...
else:
  ...
pass

Examples

Notes

Slides

References

  • Section 3 in. Prof. Dolors Ayala, 2020.

  • How to Think Like a Computer Scientist: Learning with Python 2nd Edition.

Exercises