This guide walks you through Python fundamentals using accounting examples. Work through each section and test yourself with the quizzes. Your progress is saved automatically.
Python is a general-purpose programming language. Pandas, NumPy, and matplotlib are add-on libraries — Python itself is simpler than you think.
Variable names are arbitrary labels you choose. df is just a convention — descriptive names like sales_data are actually better practice.
What does df = pd.read_csv('data.csv') do with the variable name df?
Which Python type would you use to store the value 0.065 representing a tax rate?
Navigate through the slides using the arrow keys or buttons below.
When data comes from files or user input, it is usually a string. You must convert it to a number before doing math. This is the number one source of subtle bugs.
What happens when you run: price = '50' + 10?
Lists use zero-based indexing: the first item is position 0, not 1. This is a universal programming convention.
Given items = ['Cash', 'AR', 'Revenue', 'COGS'], what does items[3] return?
Navigate through the slides using the arrow keys or buttons below.
Navigate through the slides using the arrow keys or buttons below.
A dictionary is like a lookup table: you provide the label (key) and get back the associated value. This is exactly how DataFrame column access works.
Given the account dictionary above, what does account['type'] return?
Navigate through the slides using the arrow keys or buttons below.
A pandas DataFrame is built on the same dict concept: column names are keys, column data are values (stored as lists/arrays). That is why df["column"] uses the same bracket syntax as a dict.
Why does df['Revnue'] fail with a KeyError when the column is actually named 'Revenue'?
Navigate through the slides using the arrow keys or buttons below.
Navigate through the slides using the arrow keys or buttons below.
The for loop pattern is: for ITEM in COLLECTION. Python pulls one item at a time, runs the indented code, then moves to the next. The variable name after for is your choice.
Given: for account in ["Cash", "AR", "Revenue"]: print(account) — how many times does print() execute?
Navigate through the slides using the arrow keys or buttons below.
if/elif/else checks conditions top to bottom and runs the first matching block. It is the same logic as Excel's IF() function, just written differently.
Given: if balance > 0: "Debit" / elif balance < 0: "Credit" / else: "Zero" — if balance = 0, which branch runs?
Navigate through the slides using the arrow keys or buttons below.
Navigate through the slides using the arrow keys or buttons below.
Functions let you write logic once and reuse it. Parameters with = have default values. return sends a result back to the caller.
What does calculate_tax(2000) return?
import loads external code (a library) so you can use its functions. as pd creates a shorter alias. Libraries are just organized collections of functions that other developers wrote and shared.
What does the 'as pd' part of 'import pandas as pd' do?
Read error messages from the bottom up. The last line tells you WHAT went wrong. The lines above tell you WHERE it happened (file name and line number). Errors are helpful messages, not punishment.
You see: NameError: name 'totl' is not defined. What is the most likely cause?
Navigate through the slides using the arrow keys or buttons below.
input() always returns a string, even if the user types a number. String times number repeats the string instead of multiplying. Always convert types before doing math.
What does 'ha' * 3 produce in Python?
Navigate through the slides using the arrow keys or buttons below.
When you get a KeyError on a DataFrame, run df.columns.tolist() to see the exact column names. Watch for typos, extra spaces, and capitalization differences.
You get KeyError: 'Net income' but you know the column exists. What should you check first?
A pandas DataFrame is most similar to which Python data structure?
Wednesday's lab combines everything from today: reading errors, understanding types, checking variable names, and verifying column lookups — all with an LLM as your pair programmer.
When debugging with an LLM, why is it important to document whether the suggestion was correct?