At My Fingertips

Rapid Playground

Documentation

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 PyTamaro iconellipse or PyTamaro iconcircular_sector functions.

Implement a circle and a semicircle function using the PyTamaro iconcircular_sector function. Notice that these two functions take less parameters than PyTamaro iconcircular_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 PyTamaro iconpin and PyTamaro iconcompose 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 PyTamaro iconoverlay function and the imported black and yellow colors.

eye

Loading...

The eyes function should call the eye function you implemented, placing two eyes PyTamaro iconbeside 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 PyTamaro iconrotate, PyTamaro iconabove and PyTamaro iconoverlay 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 754785f (Fri, 03 May 2024 12:21:44 GMT)