O'Reilly logo

Lean Python: Learn Just Enough Python to Build Useful Tools by Paul Gerrard

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

© Paul Gerrard 2016
Paul GerrardLean Python10.1007/978-1-4842-2385-7_3

3. Program Structure

Paul Gerrard
(1)
Maidenhead, Berkshire, UK
 

Decision Making

Some simple utilities might be a short list of statements run in order, but a useful program usually needs to make decisions and choices. The decision making in a program determines the path that the program takes. Decisions are made by if statements.

The if Statement

if statements depend on some form of test or condition. The normal format of an if statement is shown here:
if test:               # note the colon ':'.
   statement1          # The statements following the
   statement2          # if are indented and executed
   statement3          # if the test is True.
In this case, the three statements ...

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