+ 2
Is it necessary to define action related syntax while using functions in Python?
Hi Folks, Syntax:- def multiply(x, y): return x * y a = 4 b = 7 operation = multiply print(operation(a, b)) Result: 28 I wanna understand the logic while writing we declare what action system need to perform so is it mandatory to do so for every time ?
2 Réponses
+ 3
If you are talking about function name then it's not ,it's just for others understanding and yours as well ,when program gets big defining random names won't help
+ 1
imagine you wrote a program in 1000+lines of code!
it works fine. But, after 6 months you or somebody need to modify source code.
But multi(a,b) actually return a/b.
And def divide(a,b) actually returns a*b+10-math.pi
Attention, question:
How many hours you will kill to find out where is the bug,
a) if function names represent what they do
b)if function names taken from ceil and do not represent anything?