Print a value inside a buged function

Asked

Viewed 27 times

-1

I’m trying to create a program that calculates the bisection method.

I would like the user to enter the desired equation and the values of a, b and tolerance, but I’m not getting the equation input read correctly.

I also don’t know if there’s a library that can read an equation correctly. Also, I created a function to return me a value, but it is returning me something strange:

def funcao_soma(x,y):
    soma = x+y
    return soma

funcao_soma(1,5)
print("A soma foi {}".format(funcao_soma))

He returns to me:

A soma foi <function funcao_soma at 0x000001BC6E8EFF78>

Instead of the value 6.

1 answer

2


The result of your function is not being saved in any variable (line 5). It should be, for example:

resultado = funcao_soma(1,5)
print("A soma foi {}".format(resultado))

or if you do not want to use an intermediate variable:

print("A soma foi {}".format(funcao_soma(1,5)))
  • Thanks, it worked out!

  • I could mark the answer as a solution, please?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.