In this chapter you’ll:
Decide whether to execute actions with the statements if
, if
…else
and if
…elif
…else
.
Execute statements repeatedly with while
and for
.
Shorten assignment expressions with augmented assignments.
Use the for
statement and the built-in range
function to repeat actions for a sequence of values.
Perform sentinel-controlled repetition with while
.
Learn problem-solving skills: understanding problem requirements, dividing problems into smaller pieces, developing algorithms to solve problems and implementing those algorithms in code.
Develop algorithms through the process of top-down, stepwise refinement.
Create compound conditions with the Boolean operators and
, or
and not
.
Stop looping with break
.
Force the next iteration of a loop with continue
.
Use some functional-style programming features to write scripts that are more concise, clearer, easier to debug and easier to parallelize.