Python program to print the solutions of the given equation - Codicaly
In this post, we are going to write a program to find the solutions of the inputted quadratic equation. What are the Solutions of the Quadratic equation ? A quadratic equation is an equation with degree 2, i.e, the maximum power of the variable is 2. The general form of the quadratic equation is as follows. Here 'a' is the coefficient of x^2, 'b' is the coefficient of x and c is the constant. The solutions to that equation can be easily determined using the coefficients and the constants. The formula for that is below. Pre - requisites : Python basics Program : a=int(input('Enter the coefficient of x^2 with sign')) b=int(input('Enter the coefficient of x with sign')) c=int(input('Enter the constant with sign')) x1=(-b+(b**2-4*a*c)**(1/2))/(2*a) x2=(-b-(b**2-4*a*c)**(1/2))/(2*a) print("Solutions of the equation ",a,"x^2+(",b,")x +(",c,")",' are' ,x1,'and',x2) Explanations : 1. To find the...