© Joey Bernard 2016

Joey Bernard, Python Recipes Handbook, 10.1007/978-1-4842-0241-8_2

2. Numbers, Dates, and Times

Joey Bernard

(1)Fredericton, New Brunswick, Canada

The initial purpose of electronic computers was to calculate the answers to physical problems. This depended on the efficient use of numbers, and handling them correctly. This still consumed most of the CPU cycles spent in the average computer program. Along with dealing with numbers, there are many cases where you need to be able to handle dates and times. This gets a bit messy when you need to make comparisons between different time zones or across years with leap days.

2-1. Creating Integers

Problem

You need to create integers.

Solution

There are several ways to create integers . The ...

Get Python Recipes Handbook: A Problem-Solution Approach 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.