Understanding how Python handles different types of data is essential for writing clean and effective code. Here’s a quick overview of the basic data types and how to work with them.

Basic Data Types

Python provides several built-in data types that are commonly used in data engineering tasks such as data processing, validation, and transformation.

Type Description Example
int
Whole numbers
age = 30
float
Decimal numbers
price = 19.99
str
Text (strings)
name = “Alice”
bool
Boolean (True/False)
Boolean (True/False)

Each variable stores a value of a specific type:

age = 30          # int
price = 19.99     # float
name = "Alice"    # str
is_active = True  # bool

Type Conversion (Casting)

You can convert between types using built-in functions like int(), float(), str(), and bool().

Example:

Converting a string to an integer

age = 30          # int
price = 19.99     # float
name = "Alice"    # str
is_active = True  # bool

This is useful when reading input from users or files, where data often comes in as strings.