Variables and Data Types in Python

5 min read PYTHON 290 views

Understanding Python Variables

In Python, variables are created when you assign a value to them. Unlike statically typed languages like C++ or Java, Python dynamically infers the data type based on the value assigned.

Core Built-in Types:

  • int: Whole numbers (e.g., 10, -5)
  • float: Decimal numbers (e.g., 3.14, 0.001)
  • str: Text surrounded by single or double quotes
  • bool: Boolean truth values (True or False)
  • list: Ordered, mutable collections of items
python Example
Run Code
# Variables & Types Demo
age = 22                # Integer
price = 99.95           # Float
course_title = "Python" # String
is_active = True        # Boolean
skills = ["Python", "SQL", "Git"] # List

print(type(age))
print(f"Course: {course_title}, Total Skills: {len(skills)}")

Related Tutorials