Write a Python program to calculate the discriminant value


The program calculates the roots of a quadratic equation of the form ax^2 + bx + c = 0, where a, b, and c are the coefficients of the quadratic equation entered by the user.

The program first prompts the user to input the values of a, b, and c. It then calculates the discriminant value using the formula (b^2 - 4ac). The discriminant value is used to determine the number of roots of the quadratic equation.

If the discriminant is positive, there are two real solutions to the equation. The program prints the discriminant value and the message "Two Solutions." If the discriminant is zero, there is one real solution to the equation. The program prints the discriminant value and the message "One Solution."

If the discriminant is negative, there are no real solutions to the equation. The program prints the discriminant value and the message "No Real Solutions."

Source Code

a = float(input("Enter the a Value : "))
b = float(input("Enter the b Value : "))
c = float(input("Enter the c Value : "))
dis = (b**2) - (4*a*c)
if dis > 0:
    print("Two Solutions. Discriminant value is:", dis)
elif dis == 0:
    print("One Solution. Discriminant value is:", dis)
elif dis < 0:
    print("No Real Solutions. Discriminant value is:", dis)

Output

Enter the a Value : 2
Enter the b Value : 4
Enter the c Value : 6
No Real Solutions. Discriminant value is: -32.0

Example Programs