r/CodingHelp • • Feb 14 '26

[Python] i seriously just cannot understand this...

Post image

So I'm really new to coding, and I just cannot understand this. I am using a payed website that helps me learn with activities and stuff but I mean, if I don't understand how can I do it? I've researched this for more than 4 hours today and just cannot understand.

I do not understand DEF, what comes after it, RETURN AREA, or what comes under the #...

Could someone please explain?

93 Upvotes

91 comments sorted by

View all comments

Show parent comment

-14

u/Killiancin Feb 14 '26

right…

2

u/Minyguy Feb 14 '26

A function is simply a "recipe" for the computer.

A function can do almost anything, just like a cooking recipe can make almost any dish.

The 'def' simply tells the program that this is a function.

Then the name of the function.

The things in the parenthesis is called parameters, they are the "ingredients" of the function.

Then you have the actual code, which is like the actual cooking steps.

And "return" basically means "The function has completed the task, here is the result."

In this case, you have a function named area_of_circle that takes in a radius.

It then defines "pi" as 3.14.

Then, it defines "area" as pi times the radius times the radius.

And then it gives whatever that number is, back as the "final product" of the function.