← Python for Beginners
0 of 27 lessons done0%

Basics · Lesson 4 of 27

Data types

Every value in Python has a type. The four basic ones:

  • int: whole numbers like 10, -3, 0
  • float: decimal numbers like 99.5, 3.14
  • str: text in quotes like "pen", '42'
  • bool: only True or False (capital T and F)

Use type() to see a value's type:

print(type(10))       # <class 'int'>
print(type(99.5))     # <class 'float'>
print(type("pen"))    # <class 'str'>
print(type(True))     # <class 'bool'>

"42" with quotes is a string, not a number. 42 without quotes is an int.

Your task

Create these four variables:

  • count with the whole number 10
  • price with the decimal number 99.5
  • item with the text pen
  • in_stock with the value True