Help for 5.3, Step 5

Getting frustrated with this course. Exercises don’t seem to be related to the lessons before, and no solutions are given if you’re stuck. I just keep moving on, not learning anything.
This is what I’m stuck on now:

compute and return the area of a rectangle with the passed in length and width

def area(length * width):

compute and return the perimeter of a rectangle with the passed in length and width

def perimeter((length2) + (width2)):

print(“The area of this rectangle is”, area(10, 4), “square feet.”)
print(“The perimeter of this rectangle is”, perimeter(10, 4), “feet.”)
print(“The area of this square is”, area(8, 8), “square feet.”)
print(“The perimeter of this square is”, perimeter(8, 8), “feet.”)

Result:
Traceback (most recent call last):
File “python”, line 2
def area(length * width):
^
SyntaxError: invalid syntax

Does not work! Thanks for any help!

1 Like

def looking_for_area(dump_length_data, dump_width_data):

The dumping grounds for data are not calculation locations, they are the funnel for data.

Here is some info from py4e that will help.

Sorry, I really don’t understand. I guess the class has not covered this yet. Thanks for the response.

When you define a function, there are certain steps. First, you use the “def” code to define it’s name, and what arguments it takes. Then, you show, with code, what to do with the arguments. Finally, if you want the function to send any data back, you use “return” to tell it which data.

The key is, it has a certain syntax, and should be useful for any arguments for which its called.

1 Like

I am having the same issue. The class hasn’t covered the “def” function, is there any links or example that I can look up?

Sure, as a coder, you should feel free to look material up online. A Google search for “Defining a function in python” might be a good start.