+ 4

Why I should use user define function?

pleas give me short and sweet explaination

11th Oct 2019, 6:27 PM
Vijaya Ragavan S
Vijaya Ragavan S - avatar
5 ответов
+ 3
1.) To prevent code repetition. do_stuff(565) do_stuff(80) do_stuff(24789) is shorter than copypasting the whole code of do_stuff each time. 2.) Easier to read.
11th Oct 2019, 9:28 PM
HonFu
HonFu - avatar
+ 2
because you want to create your own wheels for the vehicle
11th Oct 2019, 6:51 PM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 2
Lothar thanks
11th Oct 2019, 6:57 PM
kumaran
kumaran - avatar
+ 2
User defined functions can make your programs shorter and more human-readable. Functional and object oriented programming supports dividing programs into different tasks. You can for example imagine walking, you could define walk method: def walk(): ... It could contain thousands lines of code, but only its name could describe a lot about what the function does. If you never touched this function, you would already have an image about that walk function would do some tasks related to walking, and this increases readability of code, if functions have welldescribing name. You caould also: def walk(): left_leg_up() left_leg_middle() left_leg_down() right_leg_up() left_leg_back() right_leg_forward() right_leg_down() where the function is also divided into different tasks and it can also increase readability, when each function name gives a scheme about what the function could possibly do.
11th Oct 2019, 8:33 PM
Seb TheS
Seb TheS - avatar