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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.