0
functions as object
def multiply(x, y): return x * y a = 4 b = 7 operation = multiply print(operation(a, b)) anyone it is assigned the values to a,b but at the end it shows 28? HOW
5 Réponses
+ 8
Because:
4 * 7 = 28
😐
+ 4
sayyed usman oh sorry.
Actually in the code we assigned a new name to multiply function.
Now we have two names multiply and operation which are point to the same object.
+ 4
See this code:
You see that they have the same id becausr thy are point to the same object.
https://code.sololearn.com/cTyG18ncyV9c/?ref=app
+ 2
Just function renamed like made it as alias for multiply..
So then multiply(a, b) is same as operation(a, b): it returning a*b =>7*4=28
0
is it doing like this a=x,b=y:??
im asking like this because you wroted like x*y that why
@Sadness