Variables and Data Types
Before you analyze anything, you need a way to store values in memory and refer to them later.
This is where variables come in — they let you name pieces of information that your code can use again and again.
Why Variables Matter
In data analysis, you deal with values like scores, prices, temperatures, or timestamps.
Instead of writing those values over and over, we store them in variables.
This makes your code:
- Easier to read
- Easier to update
- More flexible for re-use
Imagine managing data for a coffee shop: storing the average order price in a variable like
avg_order
is clearer than writing4.75
everywhere.
What About Data Types?
Python doesn’t treat all values the same. It automatically assigns each variable a type based on the value you assign.
This is important because:
- You can only do certain actions with certain types
- Knowing the type helps avoid errors (e.g. adding a number to a string won’t work)
As you work with real datasets, you’ll often need to check or convert types before analysis.
The Analyst’s Perspective
A good analyst not only writes correct code, but also keeps it clean and understandable.
Using well-named variables and understanding how types behave will make your work easier to debug, share, and explain.
Coming Up
Next, you'll learn how to write expressions and perform calculations using Python’s arithmetic operators.
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.