Coding Grandmaster ยท project 34 of 46 ยท premium, free for now
Draw 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.
Learn
A chart turns numbers into shapes you can compare at a glance. A bar chart is a row of rectangles whose heights are proportional to the values. With the turtle, each bar is four sides: across, up by the value times a scale, back across and down. Fill each bar with its own colour from a list.
Your task
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.
Stretch challenge
Add a label above each bar with t.write(value).
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 โ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 โ36Capstone: 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.
Start โPractise the idea
๐ข Play Turtle Studio
Write movement commands and watch a turtle draw shapes on a canvas.
FAQ
Draw a bar chart: 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
- Bug HunterA Python program prints the wrong answer. Find the one line with theโฆPlay
- Predict the OutputRead a short Python program and choose what it prints. Then watch it runโฆ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