Here is a single program that uses almost everything from all twenty-five modules: variables, types, strings, numbers, booleans, collections, loops, conditionals, functions, scope, conversion, error handling, JSON, and three algorithm patterns. Read it slowly. You can now understand every line.
EXAMPLE
loading editor…
YOUR TURN
Your turn → Every concept in this course appears here. Add a function that groups the clean records by city and prints the totals.
loading editor…
Syntax has to be exact. Every quote, bracket and parenthesis needs its partner, and in Python the spaces at the start of a line count. One slip and the program won't run; the message will say where.
✦ What you can do now
You can read a problem, break it into steps, choose the right pattern, write it in two languages, handle the data that arrives broken, and explain why your solution is efficient. That is not a beginner skill set. That is a programmer.
◈ Graded Challenge
The capstone challenge. Write a function that takes a JSON string of records (each with a name and an hours field that may be text or junk) and returns the total hours from only the valid records. Invalid entries are skipped. If the JSON itself is malformed, return 0.
Name it exactly: def total_valid_hours(text):
3 visible + 3 hidden
loading editor…
Mark this lesson complete
Signed in, your progress follows you to every device.