In: Computer Science
write a python program to do the following:
ask a student for 3 coefficients a b c using the high_school_quizz to display the solutions of a quadratic problem.
after, ask the student if he would like another quadratic equation solved
If the student answers anything but yes, the program terminates by displaying a good bye message
if the student answers yes (any form of yes should be acceptable) , the student is asked for the coefficient again and the resulting quadratic function is solved.
All greeting and goodbye messages should be surrounded by stars
Code:
import math
while(True):
a = float(input('Enter value of a : '))
b = float(input('Enter value of b : '))
c = float(input('Enter value of c : '))
d = b*b - (4*a*c)
if(d<0):
print('No Solution')
else:
r1 = (-b + math.sqrt(d))/(2*a)
r2 = (-b - math.sqrt(d))/(2*a)
print('The roots are :',r1,r2)
x = input('Do you want another solution : ')
ls = ['yes','Yes','YES']
if x in ls:
continue
else:
print('*****Good bye*****')
break
Output:
Code Screenshot: