0
import math
def Bhaskara():
a = int(input('Digite um valor para A '))
b = int(input('Digite um valor para B '))
c = int(input('Digute um valor para C '))
#(-b +- {-b² - 4 * a * c} ) / 2 * c
operacao = -b
raiz = (operacao * operacao) - 4 * a * c
raiz = math.sqrt(raiz)
divisao = 2 * c
# (operacao +- raiz) / divisao
x1 = (operacao + raiz) / divisao
x2 = (operacao - raiz) / divisao
print('X1 = {}'.format(x1))
print('X2 = {}'.format(x2))
if(__name__ in '__main__'):
Bhaskara()
Consider the code indented correctly
tip: when paste code here use the button
{}
of the formatting bar after selecting all the code - so it keeps the correct indentation.– jsbueno
About the code - when you use
int
in the value ofinput
, your program will only work for integer values - usefloat
so that it can work with decimal numbers as well.– jsbueno
You have to put inside the def a tab ! otherwise it will not understand that it is inside the def
– Shazam
Thank you all very much!!! If you hadn’t talked, I couldn’t find !!!
– Ângelo
It is not necessary to write an answer just to say "thank you". The best way to thank is accepting the answer that helped you. - Of Revision
– Isac