Question

10) p. 53, problem 2.4.7. Write a Python program that uses the Quadratic Formula to calculate...

10) p. 53, problem 2.4.7. Write a Python program that uses the Quadratic Formula to calculate the real solutions to an equation in the form x 2 +bx+c=0 . Prompt the user to enter values for a, b, and c, then display the solutions. For the purposes of this assignment, you may assume that every equation will have two distinct, real solutions. Put your program in the Homework 1 folder on your K: drive. Here is a sample run of the program to solve the equationx 2−25=0: CSC 140 North Central College Fundamentals of Computational Problem Solving Spring 2019 Enter the coefficients of a quadratic equation and I will tell you the solutions of the equation. Enter a: 1 Enter b: 0 Enter c: -25 The solutions are 5.0 and -5.0

The well-known quadratic formula, shown below, gives solutions to the quadratic equation ax2 + bx + c = 0.

x=−b±√b2−4ac2ax=−b±b2−4ac2a

Show how you can use this formula to compute the two solutions to the equation 3x2 + 4x – 5 = 0.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import math


def main():
    print("CSC 140 North Central College Fundamentals of Computational Problem Solving Spring 2019")
    print("Enter the coefficients of a quadratic equation and I will tell you the solutions of the equation.")
    a = float(input('Enter a: '))
    b = float(input('Enter b: '))
    c = float(input('Enter c: '))
    d = math.sqrt((b ** 2) - (4 * a * c))
    r1 = (-b + d) / (2 * a)
    r2 = (-b - d) / (2 * a)
    print("The solutions are {} and {}".format(r1, r2))


main()

Csc 140 North Central College Fundamentals of Computational Problem Solving Spring 2019 Enter the coefficients of a quadratic

Add a comment
Know the answer?
Add Answer to:
10) p. 53, problem 2.4.7. Write a Python program that uses the Quadratic Formula to calculate...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 4-6 on matlab 4. Write a program in a script file that determines the real roots...

    4-6 on matlab 4. Write a program in a script file that determines the real roots of a quadratic equation ax2+bx+c 0 When the file runs, it asks the user to enter the values of the constants a, b, and c. To calculate the roots of the equation the program calculates the discriminant D, given by: D b2-4ac When D 0, the program displays message "The equation has two roots," and the roots are displayed in the next line. When...

  • reword m the program into a design document diregard the m Write a C++ program that...

    reword m the program into a design document diregard the m Write a C++ program that solves a quadratic equation to find its roots. The roots of a quadratic equation ax2 + bx + c = 0 (where a is not zero) are given by the formula -b + b2 - 4ac 2a The value of the discriminant b2 - 4ac determines the nature of roots. If the value of the discriminant is zero, then the equation has a single...

  • DQuestion 19 28 pts Problem 2. Quadratic Equations A quadratic equation has the form: a bc0 The two solutions are given by the formula: 2a Write a program with a loop that a) solves quadratic equatio...

    DQuestion 19 28 pts Problem 2. Quadratic Equations A quadratic equation has the form: a bc0 The two solutions are given by the formula: 2a Write a program with a loop that a) solves quadratic equations with coefficients read from the terminal, b) visualizes the corresponding quadratic function az2 brc0using the matplotlib module. Instructions Write all code for this problem in a file p2.py 1. The program consists of a main whtle loop (an infinite loop) in which the user...

  • CODE MUST BE IN C++ Objective Create a program that provides the solution to a quadratic...

    CODE MUST BE IN C++ Objective Create a program that provides the solution to a quadratic equation. Background: A quadratic equation can be generalized by equation below: f ( x )=ax2+ bx +c Closed form solutions can be found for the zeros of a quadratic function conveniently. That is the locations where the function is equal to zero can be found by the following equation: x=− b± √ b −4ac 2a Note that depending on the sign of the expression...

  • The quadratic formula is used to solve for x in equations taking the form of a...

    The quadratic formula is used to solve for x in equations taking the form of a quadratic equation, ax? + bx + c = 0. -b + b2 - 4ac quadratic formula: 2a Solve for x in the expression using the quadratic formula. 3x2 + 27% -8,9 = 0 Use at least three significant figures in each answer. Use at least three significant figures in each answer. X = and x =

  • Question 4: Provide at least 4 test cases. Prompt the user to input 3 doubles, a,...

    Question 4: Provide at least 4 test cases. Prompt the user to input 3 doubles, a, b and c. Which will represent the coefficients in the quadratic equation ax2 + bx + c = 0. Print out the solutions (if any) of the quadratic equation. If no root exists (this happens if a == 0, or b2 <4ac) print the message No real root. Sample input/ user entries shown in red Corresponding output Enter a, b and c which represent...

  • program in assembiy language x86 In assembly language using float point Quadratic Formula Prompt the user...

    program in assembiy language x86 In assembly language using float point Quadratic Formula Prompt the user for coefficients a, b, and c of a polynomial in the form ax²+bx +C =0. Calculate and display the real roots of the polynomial using the quadratic formula. If any root is imaginary, display an appropriate message. Your result must be calculated in floating point whenever it applies, otherwise you will NOT get any credit.

  • The roots of the quadratic equation ax2 + bx + c = 0, a following formula:...

    The roots of the quadratic equation ax2 + bx + c = 0, a following formula: 0 are given by the In this formula, the term i2 - 4ac is called the discriminant. If b4ac 0 then the equation has a single (repeated) root. If -4ac > 0, th equation complex roots. Write a program that prompts the user to input the value of a (the coefficient of ), b (the coefficient of x), and c (the n has two...

  • The two roots of the quadratic equation ax2 + bx + c = 0 can be...

    The two roots of the quadratic equation ax2 + bx + c = 0 can be found using the quadratic formula as -b+ v62 – 4ac . -b-v6² – 4ac 1 X1 = - and x2 = 2a 2a When b2 – 4ac < 0 this yields two complex roots - -b V4ac – 62 -b Vac – 6² x1 = = +. . 2a 2a i. and x2 = . za 2al Using the quadratic formula the roots of...

  • for a matrix solution of the quadratic (3) Find a formula of the form x = -B C equation ax2 + bx +c = 0. Here c denotes...

    for a matrix solution of the quadratic (3) Find a formula of the form x = -B C equation ax2 + bx +c = 0. Here c denotes and 0 denotes 0 0 (Hint: First show how the square root of any number D can be obtained using a where it looks different depending matrix of the form on whether D is negative. Then use the quadratic formula.) positive or for a matrix solution of the quadratic (3) Find a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT