Variables and Data Types
Python variables, numbers, strings, booleans — the building blocks of every script
Variables store data in Python. Unlike Excel cells (A1, B2) or SQL columns, Python variables have names you choose — and Python automatically detects what type of data you stored.
Python has four basic data types you will use constantly in data work:
• int — whole numbers (age, count, year)
• float — decimal numbers (salary, percentage, price)
• str — text (names, categories, labels)
• bool — True or False (is_active, has_discount)
Python is dynamically typed — you do not declare the type. Just assign a value and Python figures it out.
Syntax
variable_name = value # assignment type(variable_name) # check the data type
Examples
Key Points
- ✓Python variable names are case-sensitive: salary ≠ Salary
- ✓Use snake_case for variable names: total_sales, not totalSales
- ✓type() tells you what data type a variable holds
- ✓int() / float() / str() convert between types — essential for data cleaning
- ✓None is Python's equivalent of NULL in SQL or blank in Excel
Practice Question
What is the data type of the value 3.14 in Python?