+ 1

why use a funcion?

27th Jun 2016, 8:39 AM
Nil Delvescovo
Nil Delvescovo - avatar
3 Answers
+ 1
I've gathered that functions could act as a shortcut for repeating a code. Example: def my_func(): print('I can') print('print all this') print('with just my_func()!') So you could print all those lines with just using "my_func()". I believe this is what you were asking.
27th Jun 2016, 3:29 PM
Dean
0
thanks
27th Jun 2016, 3:50 PM
Nil Delvescovo
Nil Delvescovo - avatar
0
Functions can be used to group together commonly used tasks. For instance, you can create a function that opens a file, closes it and returns the data so that you only ever have to call that function when you need something.
29th Jun 2016, 8:34 AM
Lari Liuhamo
Lari Liuhamo - avatar