11. The Random and Math Packages

When one of the authors was little, he didn’t like to spend a lot of time on arithmetic, because, he argued, someday everyone was going have computers to do all the arithmetic in the world. He was partly right. Arithmetic can still be useful, but the world is heavily computerized. Bar codes and cash registers do all you need, and you can always reach for your cell phone with its built-in calculator function.

But number crunching still matters. This chapter concerns not mundane arithmetic, but higher math functions, along with random, which is useful in game programs and simulations. For the most sophisticated 3-D games, you’ll need to find even more advanced packages, but for simple games, random and math suffice. ...

Get Supercharged Python: Take Your Code to the Next Level, First 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.