People often say "Python is hard because it's a programming language." The truth is: if you've used Excel formulas, you've already met most of the concepts. They just have different names. Let's translate.
| Excel concept | Python equivalent | Why they're the same |
|---|---|---|
A cell holding a value: A1 = 100 | A variable: a1 = 100 | Both are a named container for a value. |
A formula: =SUM(A1:A10) | A function call: sum(numbers) | Both take inputs and give back one output. |
A range: A1:A10 | A list: [100, 200, 300, ...] | Both are an ordered group of values. |
| A table / structured range | A pandas DataFrame | Both are rows-and-columns with named headers. |
| A VLOOKUP table | A dictionary: {"apple": 1.20, ...} | Both are a key-to-value lookup. |
IF(A1>10, "big", "small") | if a1 > 10: "big" | Both branch on a condition. |
| Filling a formula down 100 rows | A for loop | Both apply the same logic across many items. |
| A macro (VBA) | A Python script | Both are saved instructions you run on demand. |
| An add-in | A library (pandas, numpy, etc.) | Both add capabilities the base tool doesn't have. |
Excel:
=SUM(A1:A5)
Python:
numbers = [10, 20, 30, 40, 50]
total = sum(numbers)
print(total) # 150
Excel:
=VLOOKUP("apple", A1:B10, 2, FALSE)
Python:
prices = {"apple": 1.20, "pear": 1.50, "banana": 0.40}
print(prices["apple"]) # 1.2
Excel:
=IF(A1>10, "big", "small")
Python:
a1 = 14
if a1 > 10:
result = "big"
else:
result = "small"
print(result) # big
If there's only one Python concept you remember from this lesson, make it the DataFrame. It's the pandas library's word for a table of data. It has rows. It has named columns. You can sort it, filter it, group it, summarise it. It is, for all practical purposes, an Excel sheet that lives inside Python.
Once you internalise that mental model — "DataFrame = Sheet" — every example in Modules 9 through 16 will feel familiar.
import pandas as pd
# This DataFrame is basically:
# Name Sales
# Alice 1200
# Bob 800
# Carol 1500
df = pd.DataFrame({
"Name": ["Alice", "Bob", "Carol"],
"Sales": [1200, 800, 1500],
})
print(df["Sales"].sum()) # 3500 — like =SUM(B2:B4)
Try to translate each on paper before scrolling down. Answers below.
=A1 + A2=AVERAGE(A1:A5)=IF(A1="VIP", A2*0.9, A2)a1 + a2sum(numbers) / len(numbers) — or with pandas: df["A"].mean()a2 * 0.9 if a1 == "VIP" else a2