Python track
Python for Beginners
Learn Python from zero: tiny steps, easy words, 20 Beginner, 20 Intermediate and 20 Advanced questions.
Start at step 1. Each idea prepares you for the next one.
- 1Show words on screen with print
- 2Store values in variables
- 3Keep many values in a list
- 4Make choices with if and else
- 5Repeat work with loops
- 6Build reusable functions
- 7Use dictionaries for rows of data
- 8Write short list comprehensions
- 9Handle mistakes with try and except
- 10Use classes, modules and pandas
Continue where you left off
Beginner 1: Say hello
60 questions remaining in this sector
Your datasets, exercises and portfolio outputs stay inside the sector you choose.
Beginner · Strings & Indexing
15 exercises — finish them all to earn a certificate
15 questions left to earn this certificate
- Beginner 1: Say hello
- Beginner 2: Do a sum
- Beginner 3: A box called a variable
- Beginner 4: A word box
- Beginner 5: Join words
- Beginner 6: Fill in the blanks
- Beginner 7: What type is it?
- Beginner 8: Turn text into a number
- Beginner 9: Make a list
- Beginner 10: Grab the first item
- Beginner 11: Grab the last item
- Beginner 12: How many items?
- Beginner 13: Add it all up
- Beginner 14: Biggest and smallest
- Beginner 15: Add to a list
Beginner 1: Say hello
+20 XPYou are a data analyst in the Finance team. print() shows words on the screen.
Beginner 2: Do a sum
+20 XPYou are a data analyst in the Finance team. Python is a calculator. + adds numbers.
Beginner 3: A box called a variable
+20 XPYou are a data analyst in the Finance team. A variable is a labelled box that keeps a value.
Beginner 4: A word box
+20 XPYou are a data analyst in the Finance team. Text in quotes is called a string.
Beginner 5: Join words
+20 XPYou are a data analyst in the Finance team. + glues two strings together.
Beginner 6: Fill in the blanks
+20 XPYou are a data analyst in the Finance team. An f-string drops a variable inside {curly brackets}.
Beginner 7: What type is it?
+20 XPYou are a data analyst in the Finance team. type() tells you if something is a number or text.
Beginner 8: Turn text into a number
+20 XPYou are a data analyst in the Finance team. int() changes "5" (text) into 5 (number).
Beginner 9: Make a list
+20 XPYou are a data analyst in the Finance team. A list keeps many values in one box, inside [square brackets].
Beginner 10: Grab the first item
+20 XPYou are a data analyst in the Finance team. Python counts from 0, so [0] is the first item.
Beginner 11: Grab the last item
+20 XPYou are a data analyst in the Finance team. [-1] means the last item.
Beginner 12: How many items?
+20 XPYou are a data analyst in the Finance team. len() counts the items in a list.
Beginner 13: Add it all up
+20 XPYou are a data analyst in the Finance team. sum() adds every number in a list.
Beginner 14: Biggest and smallest
+20 XPYou are a data analyst in the Finance team. max() finds the biggest, min() the smallest.
Beginner 15: Add to a list
+20 XPYou are a data analyst in the Finance team. append() puts a new item at the end.
Beginner · Comparisons & ==
5 exercises — finish them all to earn a certificate
5 questions left to earn this certificate
Beginner 16: Is it bigger?
+20 XPYou are a data analyst in the Finance team. > asks a yes/no question. The answer is True or False.
Beginner 17: Is it the same?
+20 XPYou are a data analyst in the Finance team. == checks if two things are equal (one = stores, two == compare).
Beginner 18: Make a choice with if
+20 XPYou are a data analyst in the Finance team. if runs the indented line only when the question is True.
Beginner 19: Otherwise use else
+20 XPYou are a data analyst in the Finance team. else runs when the if question is False.
Beginner 20: Leave a note
+20 XPYou are a data analyst in the Finance team. A # starts a comment — a note for people, ignored by Python.
Intermediate · Dictionaries & For Loops
15 exercises — finish them all to earn a certificate
15 questions left to earn this certificate
- Intermediate 1: Repeat with a for loop
- Intermediate 2: Count to 5
- Intermediate 3: Keep a running total
- Intermediate 4: Loop with if inside
- Intermediate 5: Repeat while true
- Intermediate 6: Three choices with elif
- Intermediate 7: And / or
- Intermediate 8: Your first function
- Intermediate 9: Give the function an input
- Intermediate 10: Get an answer back
- Intermediate 11: A function for averages
- Intermediate 12: A dictionary
- Intermediate 13: Change a dictionary
- Intermediate 14: Loop over a dictionary
- Intermediate 15: A list of rows
Intermediate 1: Repeat with a for loop
+20 XPYou are a data analyst in the Finance team. for goes through a list one item at a time.
Intermediate 2: Count to 5
+20 XPYou are a data analyst in the Finance team. range(5) gives 0,1,2,3,4.
Intermediate 3: Keep a running total
+20 XPYou are a data analyst in the Finance team. Start at 0 and add each item.
Intermediate 4: Loop with if inside
+20 XPYou are a data analyst in the Finance team. Combine for and if to keep only some values.
Intermediate 5: Repeat while true
+20 XPYou are a data analyst in the Finance team. while repeats as long as the question stays True.
Intermediate 6: Three choices with elif
+20 XPYou are a data analyst in the Finance team. elif means 'else if' — another question to try.
Intermediate 7: And / or
+20 XPYou are a data analyst in the Finance team. and needs both to be True; or needs just one.
Intermediate 8: Your first function
+20 XPYou are a data analyst in the Finance team. def makes a little machine you can reuse.
Intermediate 9: Give the function an input
+20 XPYou are a data analyst in the Finance team. Things inside the brackets are inputs.
Intermediate 10: Get an answer back
+20 XPYou are a data analyst in the Finance team. return hands a result back out of the function.
Intermediate 11: A function for averages
+20 XPYou are a data analyst in the Finance team. Wrap a calculation so you can reuse it.
Intermediate 12: A dictionary
+20 XPYou are a data analyst in the Finance team. A dictionary matches a key to a value, like a phone book.
Intermediate 13: Change a dictionary
+20 XPYou are a data analyst in the Finance team. Assign to a key to add or change it.
Intermediate 14: Loop over a dictionary
+20 XPYou are a data analyst in the Finance team. .items() gives each key and value together.
Intermediate 15: A list of rows
+20 XPYou are a data analyst in the Finance team. Real tables are often a list of dictionaries.
Intermediate · Sorted() & In
5 exercises — finish them all to earn a certificate
5 questions left to earn this certificate
Intermediate 16: Sort a list
+20 XPYou are a data analyst in the Finance team. sorted() returns a new list in order.
Intermediate 17: Is it in the list?
+20 XPYou are a data analyst in the Finance team. in checks whether an item is inside a list.
Intermediate 18: Slice a list
+20 XPYou are a data analyst in the Finance team. [0:2] takes items 0 and 1 — a slice of cake.
Intermediate 19: Tidy up text
+20 XPYou are a data analyst in the Finance team. .upper(), .lower() and .strip() clean text.
Intermediate 20: Split text into parts
+20 XPYou are a data analyst in the Finance team. .split(',') cuts text at each comma.
Advanced · Comprehensions & Enumerate()
15 exercises — finish them all to earn a certificate
15 questions left to earn this certificate
- Advanced 1: List comprehension
- Advanced 2: Comprehension with a filter
- Advanced 3: Dictionary comprehension
- Advanced 4: Number each item
- Advanced 5: Tiny functions with lambda
- Advanced 6: Group totals by category
- Advanced 7: Catch an error
- Advanced 8: Clean bad values
- Advanced 9: Default values
- Advanced 10: One-line if
- Advanced 11: Make a class
- Advanced 12: Give a class a method
- Advanced 13: Import a module
- Advanced 14: Read CSV text
- Advanced 15: Work with JSON
Advanced 1: List comprehension
+20 XPYou are a data analyst in the Finance team. A one-line loop that builds a new list.
Advanced 2: Comprehension with a filter
+20 XPYou are a data analyst in the Finance team. Add if at the end to keep only some items.
Advanced 3: Dictionary comprehension
+20 XPYou are a data analyst in the Finance team. Build a dictionary in one line.
Advanced 4: Number each item
+20 XPYou are a data analyst in the Finance team. enumerate gives the position and the item.
Advanced 5: Tiny functions with lambda
+20 XPYou are a data analyst in the Finance team. lambda is a one-line function without a name.
Advanced 6: Group totals by category
+20 XPYou are a data analyst in the Finance team. Use a dictionary to add up numbers per category.
Advanced 7: Catch an error
+20 XPYou are a data analyst in the Finance team. try runs risky code; except catches the mistake politely.
Advanced 8: Clean bad values
+20 XPYou are a data analyst in the Finance team. Skip values that can't become numbers.
Advanced 9: Default values
+20 XPYou are a data analyst in the Finance team. Give a parameter a default so it's optional.
Advanced 10: One-line if
+20 XPYou are a data analyst in the Finance team. a if test else b picks one of two values.
Advanced 11: Make a class
+20 XPYou are a data analyst in the Finance team. A class is a blueprint for objects that hold data.
Advanced 12: Give a class a method
+20 XPYou are a data analyst in the Finance team. A method is a function that lives inside a class.
Advanced 13: Import a module
+20 XPYou are a data analyst in the Finance team. import borrows ready-made tools.
Advanced 14: Read CSV text
+20 XPYou are a data analyst in the Finance team. The csv module turns lines of text into rows.
Advanced 15: Work with JSON
+20 XPYou are a data analyst in the Finance team. JSON is how apps send data. json.dumps turns a dict into text.
Advanced · Groupby & Yield
5 exercises — finish them all to earn a certificate
5 questions left to earn this certificate
Advanced 16: Pandas DataFrame
+20 XPYou are a data analyst in the Finance team. pandas holds a table in a DataFrame.
Advanced 17: Filter a DataFrame
+20 XPYou are a data analyst in the Finance team. df[df[col] == x] keeps matching rows.
Advanced 18: Group a DataFrame
+20 XPYou are a data analyst in the Finance team. groupby puts rows into piles, then sum adds each pile.
Advanced 19: Generators save memory
+20 XPYou are a data analyst in the Finance team. yield hands out one value at a time instead of a whole list.
Advanced 20: Mini report script
+20 XPYou are a data analyst in the Finance team. Combine functions, loops and f-strings into a tiny report.