Question

In: Computer Science

write a python program to do the following: ask a student for 3 coefficients a b...

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

Solutions

Expert Solution

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:


Related Solutions

In python. Projectile motion: Write a python program that will ask the user for      an...
In python. Projectile motion: Write a python program that will ask the user for      an initial height y0, initial velocity v, launch angle theta, and mass m.      Create two functions, one that will calculate max height      of the projectile, and one that will calculate the range. Ask the     user which one he/she would like to calculate, then present them with the answer. (use kg, m and m/s)
Python: write a program to first ask how many tests a student has taken, then collect...
Python: write a program to first ask how many tests a student has taken, then collect all the test scores and calculate the average score. After displaying the average score, the program also assigns a letter grade to the student according to the following grading scale: Score Grade >=90 A 80-89 B 70-79 C 60-69 D <60 F This program should perform input validation for test scores and only accept a positive input value as a score (ask the user...
Calculating Delivery Cost Program in Python write a program in Python that will ask a user...
Calculating Delivery Cost Program in Python write a program in Python that will ask a user to enter the purchase total, the number of the items that need to be delivered and delivery day. Then the system displays the cost of delivery along with the total cost. Purchase total > $150 Yes Number of the items (N) N<=5 N>=6 Delivery day Same Day Next Day Same Day Next Day Delivery charges ($) 8 N * 1.50 N * 2.50 N...
Write a Python Version 3 program that will ask you the loan amount and the interest...
Write a Python Version 3 program that will ask you the loan amount and the interest rate. Then the program will tell you - The monthly payment, How many months it will take you to pay off the loan, The total amount of interest paid over the life of the loan. Program should also indicate the final payment as in many cases the final payment at the end of the loan would not be exactly the normal monthly payment and...
Write a program in Python language which will do the following: Write a program to prompt...
Write a program in Python language which will do the following: Write a program to prompt the user to enter a company name, city, state and zip code. Create a dictionary with the data. Output the dictionary. Then remove the city from the dictionary and output again.
Write a Python program that will ask the user to input a word, will return the...
Write a Python program that will ask the user to input a word, will return the first letter of the input word, and ask the user to put another word, and so on, in the form of a loop. If the user chooses to stop, he or she should input the integer "0" for the loop to stop.
Write a Python program that computes the income tax for an individual. The program should ask...
Write a Python program that computes the income tax for an individual. The program should ask the user to enter the total taxable income for the year. The program then uses the tax bracket (as shown below) to calculate the tax amount. This is based on a progressive income tax system which is how income tax is calculated in the U.S. As a result, this for example means that only income above $500,001 is taxed at 37%. Income of lower...
Write a Python program that computes the income tax for an individual. The program should ask...
Write a Python program that computes the income tax for an individual. The program should ask the user to enter the total taxable income for the year. The program then uses the tax bracket (as shown below) to calculate the tax amount. This is based on a progressive income tax system which is how income tax is calculated in the U.S. As a result, this for example means that only income above $500,001 is taxed at 37%. Income of lower...
Using Python write a program that does the following in order: 1. Ask user to enter...
Using Python write a program that does the following in order: 1. Ask user to enter a name 2. Ask the user to enter five numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5” 3. Calculate the sum of the numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5” 4. If the sum is greater than 0, print out the sum 5. If the sum is equal to zero, print out “Your account balance is zero” 6. If the sum is less than 0, print out...
Write a Python function that will do the following:1. Ask the user to input an integer...
Write a Python function that will do the following:1. Ask the user to input an integer which will be appended to a list that was originally empty. This will be done 5 times, meaning that when the input is complete, the list will have five elements (all integers).2. Determine whether each element is an even number or an odd number3. Return a list of five-string elements "odd" and "even" that map the indexes of the elements of the input list,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT