Add the Area Function
Again, you can add the tasks as a comment and then format the comment so it looks a little bit like a small task list. In the
calc module, add a function called
area() that takes two parameters called
You already have the
calc.py module, so the next step is to add a function. And this time, let’s add the parameters right away. So it should take two parameters,
def area, parenthesis, and then the first parameter is
length, and the next parameter is
width, closing parenthesis, colon.
To check if everything works, save the file and run the file in the interactive window and call it with
area(). And now you can already see this tool pop up saying
width need to be added.
01:46 I keep it simple for now and just add, like, a two and a three in it. So two times three should be six. Let’s see. Perfect. It works. So with that, you have tackled the second task of the challenge.
02:10 Before you leave the file, clean up after yourself, so now you just have the function in it. And don’t forget to save the file. And now with this in place, we can tackle the next task of this challenge.
Become a Member to join the conversation.