O'Reilly logo

Learn to Program with Python 3: A Step-by-Step Guide to Programming by Irv Kalb

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

© Irv Kalb 2018
Irv KalbLearn to Program with Python 3https://doi.org/10.1007/978-1-4842-3879-0_5

5. if, else, and elif Statements

Irv Kalb1 
(1)
Mountain View, California, USA
 

All the code we have looked at so far has essentially been linear. That is, execution of the code starts from the top and goes straight through to the bottom. The only change to this linear nature of execution is when we make a function call. Doing that transfers control to the function, but all the code inside a function also goes straight through from top to bottom. But one of the most powerful things about code is the ability to make a decision and to take a path based on that decision.

This chapter discusses the following topics:
  • Flowcharting

  • The if statement

  • Comparison operators ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required