Page 1 of 1

Python: Finding The Variable Type

Posted: Wed Aug 19, 2026 3:57 am
by The Jason

Code: Select all

name = "Amber" 

# The variable above is a str which means string.

print(type(name))

# It will display <class 'str'> for string


# Now let's look at booleans.

is_green_a_mix_of_yellow_and_blue = True

print(type(is_green_a_mix_of_yellow_and_blue))

# It will display <class 'bool'>

Code: Select all

# Let's look at integers.

the_rounded_fahrenheit_temp  = 90

print(type(the_rounded_fahrenheit_temp))

# It will display <class 'int'>


# Let's look at floats.

the_non_rounded_fahrenheit_temp is 90.5

# Due to the decimal, Python assumes this is a float.

print(type(the_non_rounded_fahrenheit_temp))

# It will display <class 'float'>