June 2015
Intermediate to advanced
298 pages
7h 15m
English
We have a number of conversion functions in the various types of data we've seen in this chapter. Each of the built-in numeric types has a proper constructor function. As with many Python functions, each of these has a number of different kinds of arguments it can handle:
int(): Creates an int from a wide variety of other objectsint(3.718) for another numberint('48879') for a string in base 10int('beef', 16) for a string in the given base—16 in this exampleint() function can ignore the extra prefix characters on numbers written in Python literal syntax: int('0b1010',2), int('0xbeef',16), and int('0o123',8)float(): Creates a float from other objectsfloat(7331) for another numberfloat('4.8879e5') for a ...Read now
Unlock full access