October 2023
Beginner to intermediate
215 pages
4h 3m
English
This chapter discusses conditional logic in Python. 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 probably be familiar if you have worked with other scripting languages.
The first part of this chapter contains code samples that illustrate how to handle if-else conditional logic in Python, as well as if-elsif-else statements. This section also shows you how to determine whether a positive integer is a leap year.
The second part of this chapter discusses Boolean operators, such as in/not/is comparison operators, as well ...
Read now
Unlock full access