def is the command you put at the front of the functions you’re defining.
You can call def when creating functions, or class methods. Make sure that your function code is on the next child indent.
There is not a lot of magic to this one!
def stands for ‘define’ as in, define a function or define a method.
Let’s take a look at a python
def code sample
Here we use def when making a regular function
def my_func(): print ("This is my function!")
This is my function!
Here we use def when making a method in a class
class Student(): def set_age(self, age): self.age = age
Bob = Student() Bob.set_age(20)
Check out more Python Vocabulary on our Glossary Page