Northstar Learning › Coding course
Learn Python by doing
325 quests · types, collections, functions, data and testing
325 questions · free · no account needed · works offline once loaded
Start learningTry today’s daily challengeWhat you will cover
- Types and conversion
- Arithmetic and precedence
- Strings and formatting
- Comparisons and boundaries
- Boolean logic
- Creating and extending lists
- Indexing and slicing
- Dictionary lookups
- Nested data
- Loops and accumulation
- Filtering and collecting
- Function calls and parameters
- Return versus print
- Defaults and keyword arguments
- Missing values and defaults
- Exceptions and conversion
- Continue and break
- List comprehensions
- Enumerate and zip
- Dictionary iteration
- Sets and membership
- Tuples and unpacking
- Sorting and key functions
- Aggregation and empty inputs
- Mutation and copies
- JSON and structured data
- CSV and file-like input
- Time differences
- Tests and debugging
- Device-report capstone
Try some questions
Tap a question to see the answer and why.
What is the final list?
results = []
for number in [3, 5]:
results.append(number * 3)
print(results)Options: [9, 15] · [3, 5, 3, 5, 3, 5] · [3, 15]
Answer: [9, 15]
number is first 3, then 5. Python multiplies each integer and appends 9, then 15.
What prints?
reading = "15" print(reading + "5")
Options: 20 · 155 · TypeError
Answer: 155
Both values are strings, so + joins them into 155. It does not add them numerically.
Which line prints 12?
def double(number):
return number * 2Options: print(double) · print(double(6)) · double = 12
Answer: print(double(6))
double(6) calls the function with number = 6. print displays its returned value, 12.
Which call correctly checks text "25" against the number 30?
def is_low(reading, threshold):
return int(reading) < thresholdOptions: is_low("25", "30") · is_low("25", 30) · is_low(30, "25")
Answer: is_low("25", 30)
The first argument may be numeric text because int() converts it. The second must already be a number for this implementation.
What is stored in message?
def battery_label(battery):
return "Low" if battery < 20 else "OK"
message = battery_label(10)
print(message)Options: True · 10 · "Low"
Answer: "Low"
The function returns the string Low. message stores that returned string, and print displays it.
What is the structure?
device = {"name": "Kitchen", "battery": 10}
results = []
results.append(device)
print(results)Options: ["Kitchen", 10] · [{"name": "Kitchen", "battery": 10}] · [10]
Answer: [{"name": "Kitchen", "battery": 10}]
results contains one item: the complete device dictionary.
Which report is supported by this evidence?
device = {
"name": "Kitchen sensor",
"online": False,
"last_battery": 5,
}
if not device["online"] and device["last_battery"] < 20:
print("Check battery; low last-known reading")Options: Battery definitely dead; restart every integration · Possible low battery; check the device · Device is working normally
Answer: Possible low battery; check the device
Offline state plus a low last-known reading supports checking the battery. It does not establish a certain cause. You have completed the guided trail; use the practice campfire to build and test your own report.
What does this program print?
reading = "15" print(int(reading) + 5)
Options: An error is thrown · 10 · undefined · 20
Answer: 20
It prints: 20. "15" is text. int() turns it into a number you can add.
Play with friends
Northstar also has a group quiz: host a live room, run one on a single screen, or send a friend a challenge link.
Open the group quiz