At My Fingertips

Smile and Frown

In this activity we will implement the smiley function that returns either a smiley face or a frown depending on the value of boolean parameter smile, to get the following images.

smile frown

Helper functions

In this activity you will need to generate multiple circles and semicircles. Pytamaro doesn't offer such functions for they can be implemented with the more general ellipse or circular_sector functions.

Implement a circle and a semicircle function using the circular_sector function. Notice that these two functions take less parameters than circular_sector.

Loading...

The mouth

Implement a mouth function that returns a frown of the given width. As you can see from the hint below, the mouth should be composed by a bigger black semicircle and a slightly smaller yellow one on top of it: use the semicircle function you implemented to generate them. Use the imported colors black and yellow and the pytamaro functions pin and compose to achieve the wanted result.

mouth

Loading...

The eyes

Implement the eye function that generates an eye composed by a bigger yellow circle and a slightly smaller black cirle on top of it: use the circle function you implemented to generate the circles. Use the pytamaro overlay function and the imported black and yellow colors.

eye

Loading...

The eyes function should call the eye function you implemented, placing two eyes beside eachother.

eyes

Loading...

The Smiley function

You can now combine your solutions into the smiley function, that should return a smiley if the given boolean smile is True, otherwise it should return a frown.

Use the pytamaro functions rotate, above and overlay as well as the circle function you implemented.

Loading...

This activity has been created by LuCE Research Lab and is licensed under CC BY-SA 4.0.

Smile and Frown

Logo of PyTamaro

PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI

Privacy PolicyPlatform Version b744b47 (Tue, 08 Oct 2024 16:30:14 GMT)