At My Fingertips

Documentation

Close the Drawbridge

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.

Loading...

We are under attack! Close the drawbridge so that the enemies can't enter the castle!

💡 Hintreplace ... with closed
Loading...
Code is messed up?Always remember that if you edit the cell and you're stuck you can reset it to the original state by clicking this symbol reset symbol on the top right of the page!

🎉 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

Logo of PyTamaro

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

Privacy PolicyPlatform Version 5c858dc (Thu, 02 Jan 2025 22:27:02 GMT)