Sobes.tech
Middle

What types of variables are there in Python?

sobes.tech AI

Answer from AI

In Python, variables do not require explicit type declaration — they are dynamically typed. Variables can be of various data types, for example:

  • Numbers: int (integers), float (floating-point numbers), complex (complex numbers)
  • Strings (str)
  • Booleans (bool)
  • Lists (list)
  • Tuples (tuple)
  • Sets (set)
  • Dictionaries (dict)

Additionally, variables can reference objects of any user-defined classes. Example:

x = 10          # int
name = "Ivan"  # str
is_active = True # bool
items = [1, 2, 3] # list