Chapter 2: Basic data types

Numbers

face Josiah Wang

Numbers can be

  • int (integers)
  • float (floating points) - these are actually equivalent to double precision in C++
  • complex (complex numbers)

There is no fine-grained distinction e.g. short, long, double, and unsigned. An int is an int, a float is a float. As simple as that.

Try typing these into an interactive Python interpreter and see what you get:

>>> type(42)
>>> type(3.412)
>>> type(3.2e-12)
>>> type(1+2j)
>>> type(5.)