+ 1
Functions as objects
can someone say why I am not getting any output https://code.sololearn.com/c4ZDXn322VVW/#py
2 Respostas
+ 4
when you invoke a function you just need the parameters for the main function in your case. and indentation was also a problem. the code below works perfectly fine.
since you define an inner function, you don't need to use the outer function as a parameter because the scope handles that for you. also. the issue here is that you can have only one return. if return is reached your code will exit the function. you can use only ONE return in a function
def calc(x,y):
return x+y
def Enter_the_no(x,y):
return calc(x,y)
print(calc(6,7))
to get all operations you want you could do this instead:
def calc(x,y):
print (x+y)
print (x-y)
print (x*y)
print (x/y)
print (x%y)
def Enter_the_no(cal,x,y):
return calc(x,y)
calc(6,7)