Understanding data types

Every data point in programming has a type. This type defines how much memory is allocated, how the value behaves, what operations Python will allow you to do with it, and more. Understanding the properties of different data types is vital for effective programming in Python.

You can always check the value's type with another built-in function, type():

>>> type(pi)
float

>>> type(name)
str

>>> type(age)
int

>>> type(sky_is_blue)
bool

As we can see, pi is a float, name is a string, age is an integer, and sky_is_blue is a Boolean value. These four types represent the most popular data types that are built into Python. The fifth one is None (of the NoneType type): the data type of one value that represents, well, nothing (a non-existent value). There are a few more data types, such as complex numbers, but we won't use them in this book.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.172.229