Total the Sales
FreeCreate <code>total</code>: the sum of all numbers in <code>sales</code>.
Show the solution
total = sum(sales)
Right — sum() adds up a whole list in one go.
Practice by topic / Python & code / Python
Python is the most popular language for automating work: cleaning data, renaming files, crunching numbers. Each exercise runs your real code in the browser and checks it. These 5 exercises build up step by step, starting with total the sales, best and worst month, add a new client.
3 of 5 free · no sign-up needed · instant feedback
Create <code>total</code>: the sum of all numbers in <code>sales</code>.
total = sum(sales)
Right — sum() adds up a whole list in one go.
Create <code>best</code> (the highest value) and <code>worst</code> (the lowest value) in <code>sales</code>.
best = max(sales) and worst = min(sales)
Good — max() and min() work on any list of numbers.
Add <code>"Delta"</code> to the end of the <code>clients</code> list.
clients.append("Delta")
Right — .append() adds one item to the end of a list.
Create <code>top3</code>: the three highest values in <code>scores</code>, highest first.
Solution and instant grading: open it in the practice app (use one of your 20 free picks, or Pro).
Try it in the live editor →Create <code>unique</code>: the regions in <code>regions</code> with duplicates removed, in alphabetical order.
Solution and instant grading: open it in the practice app (use one of your 20 free picks, or Pro).
Try it in the live editor →