CHAPTER 2

Elementary computations

It has often been said that a person does not really understand something until after teaching it to someone else. Actually a person does not really understand something until after teaching it to a computer, i.e., expressing it as an algorithm.

Donald E. KnuthAmerican Scientist (1973)

NUMBERS are some of the simplest and most familiar objects on which we can compute. Numbers are also quite versatile; they can represent quantities, measurements, identifiers, and are a means of ordering items. In this chapter, we will introduce some of the fundamentals of carrying out computations with numbers in the Python programming language, and point out the ways in which numbers in a computer sometimes behave differently ...

Get Discovering Computer Science now with O’Reilly online learning.

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