DEV Community

jrujason1001
jrujason1001

Posted on

What is "def" meaning and function in python?

Hello, Somebody can help me?
I wanted to ask, What is the meaning of "def" in python programming language? And what is the function of this "def" Keyword?

Example:
def function():
print("Hello World!")
function()

If someone can help me and the answer is helpful, I'll give you some of this cake 🍰 and It will make you proud.

Thank you!

Top comments (2)

Collapse
 
loganthomas profile image
Logan Thomas • Edited

I think of def as definition (specifically a function definition). Classes use the class statement instead of def. For example,

# This is a function
def function():
    pass

# This is a class
class MyClass:
   pass
Enter fullscreen mode Exit fullscreen mode

See 4.6. Defining Functions docs.python.org/3/tutorial/control...

See 8.6 Function definitions
docs.python.org/3/reference/compou...

Collapse
 
jrujason1001 profile image
jrujason1001

Okay, Thank you for your help. This is your cake. 🍰