Country: Niger
You are in the Niger edition. Type your country to switch.
Nigeria
Africa
Loading every country…
No country matches. Check the spelling, or choose "Any country" for the Global edition.
You are learning in the Niger edition, with examples in cfa francs and from Niger.
Your learning profile
Data skills: SQL and Python basics · Lesson 5 of 7
Python basics: variables, lists, loops and functions
Python is a readable programming language that many analysts use alongside SQL. This lesson covers variables and types, lists and dictionaries, loops and conditions, a small function, and how to read an error message, using the same example sales figures as the SQL lessons.
This lesson is complete in writing. A video for it is on its way.
What you will learn
- By the end you can create variables and say which type of value each holds.
- You can store values in a list and a dictionary and get them back out.
- You can write a for loop with an if inside it to total and count values.
- You can write a small function and read a Python error message from the last line up.
Key terms in this lesson
- Variable
- In programming, a name that refers to a stored value, such as a number or a piece of text, so the value can be used and changed later in the code.
- Data type
- What kind of value a column holds, such as a whole number, a decimal, text or a date. Numbers stored as text cannot be added or averaged.
- Python list
- An ordered collection of values in Python, written in square brackets and separated by commas, whose items are reached by position starting from zero.
- For loop
- A piece of code that repeats the same steps once for each item in a collection, such as adding every number in a list to a running total.
- Python dictionary
- A Python collection that stores pairs of keys and values in curly brackets, so a value such as a price can be looked up by its key, such as a product code.
- Traceback
- The error report Python prints when code fails, listing the lines it was running and ending with the type of error and a short message explaining it.
- Step 1: Variables and types, not started
- Step 2: Lists: many values in order, not started
- Step 3: Loops and decisions, not started
- Step 4: Dictionaries: look-ups by key, not started
- Step 5: A small function, not started
- Step 6: Reading an error message, not started
About 9 min of reading
Step 1 of 6
Variables and types
Opening this step…
Step 2 of 6
Lists: many values in order
This step opens when you finish the one above.
Step 3 of 6
Loops and decisions
This step opens when you finish the one above.
Step 4 of 6
Dictionaries: look-ups by key
This step opens when you finish the one above.
Step 5 of 6
A small function
This step opens when you finish the one above.
Step 6 of 6
Reading an error message
This step opens when you finish the one above.
Key takeaways
The key takeaways open when you finish every step.
Lesson quiz
6 questions. You need 85% to pass.
The quiz opens when you finish every step.
Stockertim Learn is education. It explains how investing works and never recommends buying or selling anything.
Popular this week: Basics: BeginnerNigerien markets: Beginner