what are def and how to use it? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

what are def and how to use it?

also a little about class would also be appreciated.

3rd Dec 2016, 6:00 PM
Sanju
Sanju - avatar
2 Réponses
+ 2
"def" is used to define functions. Using this you can make your own functions with your own conditions. For example: def my_func(): print("Hello world!") Now that I've defined a function above, I can execute it whenever I like: print(my_func()) Output: Hello world! Hope this helped!
3rd Dec 2016, 6:11 PM
Zahin Zaman
Zahin Zaman - avatar
+ 1
def is a keyword to define functions and class keyword is to define a class object def function_name(): ## code goes here class ClassName(object): ## Code goes here
3rd Dec 2016, 6:09 PM
Nedim Kanat
Nedim Kanat - avatar