Jan-06-2021, 07:04 PM
Hello guys, I am trying to learn Python and I wonder if there is a better, more efficient solution to this.
Can you tell me if Option 1 or 2 is more efficient? Or maybe if there is a cleaner way to use multiple functions.
Thanks
def firstCalc():
a = 2+2
return a
def secondCalc(a):
b = 3+a
return b
def thirdCalc(b):
c = b+7
return c
# Option 1
x = thirdCalc(secondCalc(firstCalc()))
print(x)
# Option 2
a = firstCalc()
b = secondCalc(a)
c = thirdCalc(b)
print(c)I have a code which i seperated in 3 functions to have an easier overview of the code. I use the value I retrieve from the first function in the second function, and the second value in the third function. Can you tell me if Option 1 or 2 is more efficient? Or maybe if there is a cleaner way to use multiple functions.
Thanks
