c = int(input('Enter 2 to start'))
while c != 1:
import math as m
a = int(input('Write a: '))
b = int(input('Write b: '))
c = int(input('Write c: '))
D = (b ** 2) - (4 * a * c)
print ('D =',D)
if D > 0:
print('D > 0')
x = (-b + (m.sqrt(D))) / (2 * a)
x1 = (-b - (m.sqrt(D))) / (2 * a)
print ('x1 =',x)
print ('x2 =',x1)
elif D == 0:
print('D = 0')
x = -b / (2 * a)
print ('x =',x)
else:
print('D < 0')
print ('No roots')
c = int(input('Enter 1 to quit or 2 to repeat'))
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
c = int(input('Enter 2 to start'))
while c != 1:
import math as m
a = int(input('Write a: '))
b = int(input('Write b: '))
c = int(input('Write c: '))
D = (b ** 2) - (4 * a * c)
print ('D =',D)
if D > 0:
print('D > 0')
x = (-b + (m.sqrt(D))) / (2 * a)
x1 = (-b - (m.sqrt(D))) / (2 * a)
print ('x1 =',x)
print ('x2 =',x1)
elif D == 0:
print('D = 0')
x = -b / (2 * a)
print ('x =',x)
else:
print('D < 0')
print ('No roots')
c = int(input('Enter 1 to quit or 2 to repeat'))