Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import time
- print('ax^2 + bx + c = 0')
- print('Considerando a equação de segundo grau acima, dê os valores de: ')
- a = float(input('a -> '))
- b = float(input('b -> '))
- c = float(input('c -> '))
- d = b ** 2 - 4 * a * c
- x1 = (-b + math.sqrt(d)) / 2 * a
- x2 = (-b - math.sqrt(d)) / 2 * a
- print('-'*50)
- print('CALCULANDO AS RAÍZES DE: {}x^2 + {}b + {}'.format(a, b, c))
- print('-'*50)
- time.sleep(3)
- if x1 == x2:
- print('r = {:.2f}'.format(x1))
- else:
- print('r1 = {:.2f} \nr2 = {:.2f}'.format(x1, x2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement