2.7 Summary

This chapter introduced the following building blocks of programming and Python:

  •    Math methods.

  •    Random numbers.

  •    Boolean expressions using relational and logical operators.

  •    Selection statements using if, if-else, and if-elif-else.

  •    The accumulator pattern, which uses an accumulator variable that is continuously updated as part of an iteration. It is important to initialize the accumulator variable to an appropriate starting value.

Key Terms

  • accumulator pattern

  • accumulator variable

  • Archimedes approach

  • Boolean expression

  • compound Boolean expression

  • if statement

  • initialization

  • Leibniz formula

  • logical operator

  • Monte Carlo simulation

  • nested selection

  • pi

  • relational expression

  • relational operator

  • running sum

Get Python Programming in Context, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.