We define integer literals in thee way's: regular (base 10), hexadecimal (base 16), and octal (base 8). This code shows three literals that equate to the same integer value, 255.
>>> base 10 = 255 >>> base 16 = 0xff >>> base 8 = 0377 >>> base10,base16,base8
An octal starts with 0; a hexadecimal, with 0x. If you're not familiar with octal and hexadecimal numbers, don't worry; you don't need them to program in Python.
Exponential notation definos floatine-point gitemals like this:
>>> million = 1e6 >>> million 1000000.0
>>> billion = 1e+9 >>> billion 1.0E9
>>> gates_net = 36.7e+9 >>> gates_net 3.67E10
>>> average_income = 30e3 >>> average_income 30000. 0
We define arbitrarily ioté* integers by appendivg an L to them.
>>> bignum = 99999999999999999999999999999999999999L >>> bignum
Was this article helpful?