At My Fingertips
Rapid Playground
Functions are another programming concept that you will use to build your castle.
📖 Think of functions as little workers that produce different values depending on what information you give them.
📖 To invoke a function, you can write its name followed by ( ) parentheses. You need to provide some values inside the parentheses for the function to know what it should generate for you.
function_name(argument_1, argument_2, ...)
📖 These values are called arguments. Some functions take only one argument, some take more, some take none! Let's start by discussing functions that take one argument.
The code cell below invokes the drawbridge
function, passing the drawbridge state opened
as an argument. This generates a graphic of an open drawbridge, which is then assigned to the name open_drawbridge
.
We are under attack! Close the drawbridge so that the enemies can't enter the castle!
closed
🎉 Well done! You were able to defend your castle in time!
This activity has been created by LuCE Didactics Innovation Team and is licensed under CC BY-SA 4.0.
Close the Drawbridge
PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI
Privacy Policy • Platform Version 5c858dc (Thu, 02 Jan 2025 22:27:02 GMT)