At My Fingertips
Rapid Playground
In this activity we are going to implement a function that generates a three-leaf clover or a four-leaf clover, like these ones:
The first thing you will have to do is implement a leaf function, that, since leaves can be represented as hearts, will return a green heart.
We have an activity that will guide you through the implementation of a heart function, so we suggest solving that first, copy-pasting your code in here and adapting it so that the leaf function returns a heart of the given LEAF_COLOR
color.
Let's now implement the stem function that returns a rectangle of color LEAF_COLOR
, with width of 1/5 compared to the given leaf_radius, and height of double the given leaf_radius
Let's now implement a clover function that will generate a three leaf clover or a four leaf clover, given the leaf_radius and a boolean value four_leaves.
If the four_leaves argument is True
, the function should return a four-leaf clover, otherwise, it should return a three-leaf clover. Use conditional statements to work with boolean values!
There are two (among many more) suggested strategies:
You can now run the following cells to see your results!
This activity has been created by LuCE Research Lab and is licensed under CC BY-SA 4.0.
Clover
PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI
Privacy Policy • Platform Version c08406b (Wed, 20 Nov 2024 12:30:00 GMT)