+ 1
what does <function f at 0x00C15660>mean looks like its throwing excempt,plz help
x=5 y=5 if x==y: print ("they r equal") else: print("they r not") a = int(input("enter 1st number 'a' ")) print (" entered number is",(a)) b = int(input("enter 2nd number 'b'")) print (" entered number is",(b)) def f(a,b): (a**2)+(b**2)+(2*a*b) print(" sq of (a+b) is",(f)) <<<This was the code >>> they r equal enter 1st number 'a' entered number is 5 64 enter 2nd number 'b' entered number is 64634 sq of (a+b) is <function f at 0x00C15660> <<< this was the output>>> plz explain what is trying to communicate to me ....? and why is not the function printed....? what change has to be made to the code.....?
2 Respuestas
+ 5
change
print(" sq of (a+b) is",(f))
to
print(" sq of (a+b) is",(f(a, b))
this happened because you did not invoke the f function, but simply printed it
also, add return just before (a**2)+.... that is inside the f function, otherwise nothing will be returned and the result will be None as no value was returned from f
f should look like this:
def f(a,b):
return (a**2)+(b**2)+(2*a*b)
+ 1
f(a,b) is a function taking two arguments.
so you need to call it by writing
print(" sq of (a+b) is",f(a,b))
in the print statement