At My Fingertips
Rapid Playground
The Sustainable Development Goals were adopted by the United Nations in 2015. There are 17 goals. The SDG color wheel represents the 17 goals in a circular graphic with 17 segments.
Let's start by capturing the 17 goals. We will model each goal as an object consisting of three parts:
We create a Python dataclass to model a goal this way.
Now we will create 17 Goal objects, one for each SDG, and put them in a list named goals
.
Then we print the title of goal number 4.
Before creating the wheel, let's compose a "goal bar", a rectangle colored in the goal's color, overlaid with the goal's number in large white text and the goal's title in smaller white text.
Now that we have our goals, we can compose our color wheel:
One way to decompose the SDG color wheel is to overlay a small white circle on top of a composition of 17 differently colored circular sectors. Each circular sector is 360 / 17 degrees wide (there are 17 SDGs). To separate the circular sectors, we overlay the composition with a composition of 17 white spokes, where each spoke a rectangle going from the center to the outer periphery of the wheel.
Create functions to compose the various parts of the color wheel. Iterate over the 17 goals to create the 17 circular sectors, and also iterate to create the 17 white spokes.
You practiced using a dataclass, using a list, and composing a regular rotational graphic.
You also learned about the Sustainable Development Goals. While we did not use the titles in this activity, you may want to read the titles to understand what the SDGs actually are about. And you may want to learn more about each goal on the official SDG website.
This activity has been created by LuCE Research Lab and is licensed under CC BY-SA 4.0.
SDG Color Wheel
PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI
Privacy Policy • Platform Version 1cd5229 (Tue, 05 Nov 2024 16:55:57 GMT)