Variables can store different types of data. The three basic data types in Python are:

Data TypePython NameDescriptionExamples
IntegerintWhole numbers5, 10, -3, 0
FloatfloatDecimal numbers1.5, 3.14, -0.5
StringstrText (characters)"hello", 'Python', "42"
BooleanboolTrue or FalseTrue, False

Checking Data Types

You can check the type of any value or variable using the type() function:

>>> type(42)
<class 'int'>
>>> type(3.14)
<class 'float'>
>>> type("hello")
<class 'str'>
>>> type(True)
<class 'bool'>

Important Distinction

A number written inside quotes is a string, not a number:

>>> type(42)
<class 'int'>
>>> type("42")
<class 'str'>

42 and "42" look similar but are completely different types. You can do arithmetic with the integer 42, but not with the string "42".

What Type Is It?

For each value below, decide whether it is an int, float, str, or bool.

"Hello World"

str — it is text enclosed in quotes.

3.14

float — it is a decimal number.

100

int — it is a whole number.

"250"

str — even though it looks like a number, the quotes make it a string.

True

bool — it is a Boolean value.

7.0

float — any number with a decimal point is a float, even if the decimal part is zero.