Can anyone explain in simple words what def main is? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

Can anyone explain in simple words what def main is?

like when to use it?

18th Sep 2016, 7:39 PM
Zehwan Rehmani
Zehwan Rehmani - avatar
8 Réponses
+ 2
def main defines a function called main that you can then use in your script. def main(): print("Hello world!") main()
18th Sep 2016, 7:58 PM
Zen
Zen - avatar
+ 2
It is used for reusing code. With that you can take less time to make something multiple times. For example: def main(): print ("Example") #And then only you need to put main() instead of print("Example") multiple times
22nd Sep 2016, 8:04 PM
Rangas
Rangas - avatar
+ 1
def in simply mean is assigning a definition to var e.g def main(): print ("text") main () this is a simple code that means we define main() to print our text.
21st Sep 2016, 10:13 AM
Animesh Roy
Animesh Roy - avatar
0
For the same result
22nd Sep 2016, 8:04 PM
Rangas
Rangas - avatar
0
thanx animesh
23rd Sep 2016, 3:07 AM
Ahmed Kamal
Ahmed Kamal - avatar
0
can we write something within the parenthesis
23rd Sep 2016, 3:13 AM
Ahmed Kamal
Ahmed Kamal - avatar
0
main is like container of a panel as in html. is it the right simulation
23rd Sep 2016, 3:21 AM
Ahmed Kamal
Ahmed Kamal - avatar
- 1
zen brother how r u
21st Sep 2016, 5:09 PM
Ahmed Kamal
Ahmed Kamal - avatar