CHAPTER 2
CONDITIONAL LOGIC IN PYTHON
This chapter is a continuation of the previous chapter, which discusses conditional logic, for loops, and while loops. Various code samples are included to illustrate each of these topics in Python.
The first part of this chapter briefly discusses precedence of operators as well as reserved words in Python. Next are Python-based code samples of various types of loops, including nested loops.
The second part of this chapter discusses conditional logic, as well as control structures and user-defined functions. Virtually every Python program that performs useful calculations requires some type of conditional logic or control structure (or both). Although the syntax for these features is slightly different from other languages, the functionality will be familiar to you.
NOTE
The scripts in this book are for Python 3.x.