Python program to find all roots of a quadratic equation


Asked by admin @ in Computer Science viewed by 366 People


Write a python program to find all roots of a quadratic equation​

Answered by admin @



This program computes roots of quadratic equations when coefficients of a,b and c are known.

The standard form of Quadratic Equation is:

ax² + bx + c = 0 where,

a,b and c are real numbers and a ≠ b

⠀⠀⠀: So let's cöde for this program :

a=int(input("Enter a: "))

b=int(input("Enter b: "))

c=int(input("Enter c: "))

D=(b* *2)-(4*a*c)

print("The value of discriminant is",D)

sol1 = (-b+D* *0.5/2*a)

sol2 = (+b-D* *0.5/2*a)

print("The roots of this quadratic equations are", sol1, "and" ,sol2)

Here first , we need to find the discriminant and then roots.

Note: You can change the values of a ,b and c in the above program to test its output .


Similar Questions

Algorithm to find the roots of a quadratic equation

Asked by admin @ in Math viewed by 359 persons

Write an algorithm to find root of quadratic equation

Find the roots of the following quadratic equation

Asked by admin @ in Math viewed by 303 persons

Question 1 Find the roots of the following quadratic equations, if they exist, by the method of completing the square: (i) 2x^2 - 7x + 3 = 0 (ii) 2x^2 …

Find quadratic equation from sum and product of roots

Asked by admin @ in Math viewed by 300 persons

How to find quadratic equation from sum and product of roots are given?

How to find all real solutions of a quadratic equation

Asked by admin @ in Mathematics viewed by 351 persons

Find all real solutions of the quadratic equation. (Enter your answers as a comma-separated list. If there is no real solution, enter NO REAL SOLUTION.) x2 − 6x + 1 …

If is a root of the quadratic equation

Asked by admin @ in Math viewed by 308 persons

If -5 is a root of the quadratic equation 2x2+px-15=0

How to find third term of quadratic equation

Asked by maham237 @ in Mathematics viewed by 450 persons

A quadratic pattern has a second term equal to 1,a third term equal to -16 and a fifth term equal to -14 1.1.1.calculate the second difference of this quadratic pattern …

Which system of equations can be used to find the roots of the equation ?

Asked by maham237 @ in Mathematics viewed by 385 persons

Which system of equations can be used to find the roots of the equation 4x2 =x3 +2x?

How to solve quadratic equations using the square root method

Asked by admin @ in Mathematics viewed by 305 persons

How can square roots be used to solve quadratic equations?

What is the square root method when solving quadratic equation

Asked by admin @ in Mathematics viewed by 292 persons

How can square roots be used to solve quadratic equations?

How do you find the roots of a polynomial equation

Asked by admin @ in Mathematics viewed by 346 persons

How to find the roots of a polynomial equation?

How do you find the equation of a quadratic function

Asked by admin @ in Mathematics viewed by 312 persons

Write the equation of the quadratic function in standard form represented by the graph

How to find the y intercept of a quadratic equation

Asked by admin @ in Mathematics viewed by 286 persons

What is the y-intercept of this quadratic function? f(x)=-x2+10x-22

A quadratic equation whose one root is 3 is

Asked by admin @ in Math viewed by 309 persons

A quadratic equation whose one root is 3 is​

If the quadratic equation px2 2 root 5 15

Asked by admin @ in Math viewed by 309 persons

If the quadratic equation px2 - 2√5px + 15 = 0 has two equal roots then find the value of p.

If 1 p is a root of quadratic equation

Asked by admin @ in Math viewed by 304 persons

If (1 - p) is a root of quadratic equation x2 + px + (1 - p) = 0 then find its roots?

Most viewed questions in Computer Science


A programmer mistakenly writes gor instead of for

Asked by admin @ in Computer Science viewed by 19030 persons


Domestic data entry operator ncert book class 9 solutions

Asked by admin @ in Computer Science viewed by 15815 persons


Information technology code 402 class 9 solutions chapter 1

Asked by admin @ in Computer Science viewed by 10977 persons



Ncert solutions for class 8 computer chapter 1 computer system

Asked by admin @ in Computer Science viewed by 10407 persons


A scrum team works on a 4 weeks sprint

Asked by admin @ in Computer Science viewed by 8723 persons


Which of the following occupies more memory in c

Asked by admin @ in Computer Science viewed by 8145 persons



A database of motor vehicles has the base entity

Asked by admin @ in Computer Science viewed by 7845 persons


The network architecture can be termed as a mcq

Asked by admin @ in Computer Science viewed by 6492 persons


Cat5 and cat6 cabling refer to which reference model layer

Asked by admin @ in Computer Science viewed by 5795 persons



Class 7 computer chapter 3 questions and answers

Asked by admin @ in Computer Science viewed by 5696 persons


Choose the correct options about usability and user experience

Asked by admin @ in Computer Science viewed by 5479 persons


Which advocates daily team meetings for coordination and integration

Asked by admin @ in Computer Science viewed by 4986 persons



Which three security features match the database security level

Asked by admin @ in Computer Science viewed by 4976 persons


Which of the dbms package is not available

Asked by admin @ in Computer Science viewed by 4688 persons


________ aid a business grow and attain its objectives

Asked by admin @ in Computer Science viewed by 4492 persons