Coding Grandmaster ยท project 36 of 46 ยท premium, free for now
Capstone: a report table
Write grade(score) (A for 80 or more, B for 70 or more, otherwise C) and print the ranking, highest first, as an aligned table with a header, then the average (2 decimal places) and the name of the top scorer.
Learn
Data science ends with a report: rank the results, label them and summarise. Format specifiers line the columns up: {name:<9} pads to 9 on the left-aligned side and {score:>5} right-aligns in 5 spaces, so numbers sit neatly under each other. Putting the labelling rule in a small function keeps the main code readable.
Your task
Write grade(score) (A for 80 or more, B for 70 or more, otherwise C) and print the ranking, highest first, as an aligned table with a header, then the average (2 decimal places) and the name of the top scorer.
Stretch challenge
Add a column showing how far each score is from the average.
Press Run to see what your program prints.
More in this module
Keep going in Coding Grandmaster
Records, filters and rankings
Keep the students whose score is at least cutoff, sort them by highest score (ties by name), print how many qualified, and print the first top of them as a numbered list.
Start โ32Group by: totals per region
For every sale of at least minimum, add it to its region. Print one line per region (alphabetical) like east: total 360, average 180.0, orders 2.
Start โ33Cleaning messy data
Write fill_missing(values) that replaces each None with the mean of the other values rounded to 1 decimal place, and remove_duplicates(values) that keeps only the first of each repeated value in order. Print both results for the readings.
Start โ34Draw a bar chart
Draw one filled bar for each value, 40 wide and 15 times the value tall, 50 apart, starting at x = -150 along the line y = -100, using a different colour from the list for each.
Start โ35Draw a line chart
Draw an x axis and a y axis from the origin at (-150, -100), then plot the sales as dots (50 apart across, 5 times the value up) joined by lines.
Start โPractise the idea
๐ Play Data Detective
Use mean, median and mode to describe a set of data and compare what each tells you.
FAQ
Capstone: a report table: common questions
I am stuck. What can I do?
Press Hint for a nudge, read the message next to each goal, and compare your code with the lesson text. If you still need it, Show answer reveals a model solution. Try to type it yourself rather than copy it.
Does my work get saved?
Your ticks and XP are saved in this browser, and in your account if you log in. The code you type is not stored on a server.
Start a conversation
Enjoying coding? Meet a teacher.
Tell us the learner's age, country and what they would like to build, and we will suggest a class. A parent or guardian can make the enquiry.
- Tell us the learnerโs age or grade and goals
- Weโll suggest a suitable class or learning path
- Weโll confirm format, timing and fees with a parent or guardian
Play it, don't just read it
Write some code right now
Free games that need no sign-up. Pick one and play for five minutes.
Pick a game
- Predict the OutputRead a short Python program and choose what it prints. Then watch it runโฆPlay
- Bug HunterA Python program prints the wrong answer. Find the one line with theโฆPlay
- Code BuilderThe lines of a Python program are mixed up. Tap them into the rightโฆPlay
- Code JungleWrite real Python to guide Miko the monkey to every banana. 24 levels:โฆPlay