# Python program to determine the roots of a quadratic equation

Here is the code for a python program that determines whether the roots of a quadratic equation are real or imaginary. If the roots are real, the program will print the value of the roots.

```
# Python program to determine the roots of a quadratic equation

a = int(input('Enter the coefficient of x2: '))
b = int(input('Enter the coefficient of x: '))
c = int(input('Enter the value of constant: '))
disc = b ** 2 - (4 * a * c)
roots1 = (-b + ( b ** 2 - (4 * a * c) )**(1/2)) / (2*a)
roots2 = (-b - ( b ** 2 - (4 * a * c) )**(1/2)) / (2*a)
if disc >= 0:
print('Roots are real.')
print(roots1)
print(roots2)
else:
print('Roots are imaginary.')

# This code is contributed by Ahmad Shafiq

``` ## Love this read? Subscribe to Modernage!

Do you have any queries? You can ask in the comments. We, at Modernage answer each and every question, asked in the comments, so If you have any queries, or you want to know about any specific platform you can ask in the comments below

## Author ## More Articles.  ### Python program to separate the characters of a string and to find the length of the string.

First, We have to store the first and last names in two variables. Then, use concatenation to concatenate yournames and then print it. Also, print  ### Python program to find multiples of an integer defined by user and in the range which is also defined by the user. Implementing using both while loop and for loop.

Here is the code for a python program to find multiples of 5 in the range defined by the user. Implementing using both while loop  ### What is Selfie Art World? Best place to visit in Pakistan

Art represents the cultural heritage of a society. It influences society by changing opinions.  It is the phenomenon of art that helps humans to understand

## Python

### Python program to print star patterns in python ## More Articles.  ### 7 Proven ways How to make money with cryptocurrency 

The process of making money from cryptocurrency in 2022  ### What is Blockchain: A beginners guide to blockchain

With the technology evolving more than ever, we have  