Module 2: Python Basic Syntax and Data Types
Data Types
Every value in Python has a type — it tells Python what kind of data you have. This matters a lot for data science later.
About 12 minutes
The four types you'll use first
int
Whole numbers: 7, -3, 0
↓
float
Decimals: 3.14, 2.0
↓
str
Text: "hello"
↓
bool
True or False
Example code
age = 25 # int price = 9.99 # float name = "Sam" # str is_student = True # bool print(type(age), type(price), type(name), type(is_student))
Checking types with type()
type(value) tells you what kind of value it is. Useful when debugging or learning.
In data science, you'll mostly work with numbers (int/float) and text (str) in tables — Pandas handles types for you later.
Practice
Create one variable of each type (int, float, str, bool). Print each value and its type.
Key takeaways
- int = whole numbers, float = decimals, str = text, bool = True/False.
- type(x) shows the type of x.
- Choosing the right type helps avoid bugs later.
Quick check: Data Types
Question 1 of 2
What type is 3.14?