Why do we need this last function(£ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why do we need this last function(£

here is the code def function(): print(“this is fun”) function() I do not understand why do we need to call function() at the end in order to print ?

25th Nov 2019, 5:40 PM
THEGreatGatsby
THEGreatGatsby - avatar
2 Answers
+ 3
Without calling a function how do you expect it to do something? Edit: If you need a pen then you have to ask for it to someone, without you asking how would someone give you a pen not knowing that you don't have one.
25th Nov 2019, 5:45 PM
Avinesh
Avinesh - avatar
+ 3
a function is like a cow that eats grass(the input) which its body turns into milk which a farmer(function() function call) then milks(the ouput) def function(): print("this is fun") the above two lines only define what will the work of the function be(so no action done) and the below line calls the function(now this will do some action) function()
25th Nov 2019, 7:05 PM
Rohit