Python Basics for Analysts
Part of the Data Analyst Roadmap
In short
Excel starts sweating at a few lakh rows and you can't rerun last week's clicks. A little Python fixes both. You need maybe five ideas, not a computer science degree.
Just enough Python — variables, lists, dictionaries, loops, and functions — to read and write basic analysis scripts, without needing a full software engineering background.

Think of it like this
Labelled jars in the kitchen
A variable is a labelled jar: 'sugar' holds a value. A list is the shelf of jars in order. A dictionary is the label-to-jar lookup. A loop is checking every jar one by one, and a function is the recipe you reuse daily.
Watch it happen
A loop walks through a list
1/5A list of daily sales in rupees: sales = [420, 380, 515, 290, 610]. Positions start at 0, not 1.
The big ideas
What you need to know
Variables and types
A name pointing at a value. Know the four basics: int, float, str (text) and bool (True or False).
Lists and dictionaries
Lists keep things in order, like [10, 20, 30]. Dictionaries map keys to values, like {"city": "Pune", "orders": 42}.
Loops and if
for repeats work over every item. if decides what to do. Together they replace hours of manual checking.
Functions
Wrap steps you repeat into def clean_name(x): and call it anywhere. Less copy-paste, fewer silly mistakes.
See it in code
Walk through the code
1sales = [420, 380, 515, 290, 610]2 3total = 04for amount in sales:5 total += amount6 if amount < 300:7 print("Slow day:", amount)8 9def average(values):10 return sum(values) / len(values)11 12print("Total:", total)13print("Average:", average(sales))1/4A list holds the five daily sales in order.
A tiny script with every basic idea in it. It prints the slow day, then Total: 2215 and Average: 443.0.
Save yourself the pain
Common mistakes
Oops
Mixing tabs and spaces, or forgetting to indent after a colon.
Do this instead
Python uses indentation as structure. Use 4 spaces everywhere; your editor can do it for you.
Oops
Panicking at a red error and closing the notebook.
Do this instead
Read the last line of the error first. It usually names the problem, like NameError or TypeError, and the line number.
Your mission
Your first analysis script
Quick check
sales = [420, 380, 515]. What does sales[1] give you?
Go deeper
- 1Complete a beginner Python course focused on data, not general software development.
- 2Practice writing a simple script that loops through a list and computes a summary.
- 3Learn to read Python error messages instead of getting stuck on them.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.