Python Data Structures and Algorithms
上QQ阅读APP看书,第一时间看更新

Numeric Types

All numeric types, apart from bool, are signed and they are all immutable. Booleans have two possible values, True and False. These values are mapped to 1 and 0, respectively. The integer type, int, represents whole numbers of unlimited range. Floating point numbers are represented by the native double precision floating point representation of the machine. Complex numbers are represented by two floating point numbers. They are assigned using the j operator to signify the imaginary part of the complex number, for example:

a = 2+3j

We can access the real and imaginary parts with a.real and a.imag, respectively.