import math
def quadratic(a, b, c):
d = (b * b) - (4 * a * c)
if d < 0 or a == 0:
return None
roots = []
if d == 0:
roots.append((-b) / (2 * a))
else:
r2 = (-b - math.sqrt(d)) / (2 * a)
r1 = (-b + math.sqrt(d)) / (2 * a)
roots.append(r1)
roots.append(r2)
return roots

![None [1.0] [1.4142135623730951, -1.4142135623730951] Process finished with exit code o](http://img.homeworklib.com/questions/333f7a20-8f68-11eb-b82b-c1b177a7335c.png?x-oss-process=image/resize,w_560)
3. Produce the function quadratic(a,b,c) where a, b, and c are the coeffi- cients of the...
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...
1) Using the Quadratic class you have already developed, make it Comparable. A Quadratic is bigger than another Quadratic if it opens faster. 2) Write a driver for Quadratic.java. In the driver program create a few objects and compare them . then create a list of those objects and sort them. import java.util.*; import java.lang.*; class Quadratic{ private double a,b,c; // Determines/declares the class variables to store the coefficients Quadratic(){ // Determine/declare the default constructor ...
C program that uses
pointers as function arguments to do the
following:
To exemplify pointers, we will be doing quadratics. Remember that a quadratic expression is of the form: ax2 + bx + c where a. b, c are constant and a is not 0. You will scan in the values a. b. and c. With these values, you will write three functions: quadraticFormula quadraticVertex quadratic Info The first function will perform the quadratic equation to find the roots of...
Using matlab and if/else statement please!
Write a function that determines the real roots of a quadratic equation ax2 + bx + c = 0. To calculate the roots of the equation, the function calculates the discriminant D, given by: D = b2-4ac If D> 0, the code should display "The equation has two roots" and print the values on a new line. If D 0, the code should display "The equation has one root.", and print the value on...
C++ The roots of the quadratic equation ax² + bx + c = 0, a ≠ 0 are given by the following formula: In this formula, the term b² - 4ac is called the discriminant. If b² - 4ac = 0, then the equation has a single (repeated) root. If b² - 4ac > 0, the equation has two real roots. If b² - 4ac < 0, the equation has two complex roots. Instructions Write a program that prompts the...
write a function of quadratic choice. it must take in at least one parameter, and perform some task. the reslut will be returned to main, and printed. here is the sample but this sample still not complete because this sample still need to return root1 and root2 to the main. sample: def juneQuadratic(a,b,c): root1 = (-b + math.sqrt(b**2 - (4*a*c)) )/2*a root2 = (-b - math.sqrt(b**2 - (4*a*c)) )/2*a return (root1,root2) def main(): rootsTupleFromFunction = juneQuadratic(2,8,5) print(rootsTupleFunction) print("Root 1...
A quadratic equation is generally represented as, ax^2 + bx + c The root(s) of the above quadratic equation is computed using the following formula, root1 = (-b + sqrt(D))/ 2a root2 = (-b - sqrt(D))/2a Where D is the discriminant of the quadratic equation and is computed as, D = b^2 - 4ac Given the value of D, the roots of a quadratic equation can be categorized as follows, D > 0 : Two distinct real roots D =...
write a C programming code for the following prompt. please
use stucture concept and test if the code works perfectly.
Project Description: In this project, you will write a program to calculate the roots of a quadratic equation. Structure concepts will be used in this project. Your program will prompt the user to enter the coefficients of a quadra coefficientsType. Then it will compute the roots of the quadratic equation and store the result in a structure variable of type...
Use Python Programming.
Design a class named Quadratic Equation for a quadratic equation ax + bx+c 0. The class contains: • The data fields a, b, and c that represent three coefficients. . An initializer for the arguments for a, b, and c. • Three getter methods for a, b, and c. • A method named get Discriminant() that returns the discriminant, which is b- 4ac The methods named getRoot 1() and getRoot 2() for returning the two roots of...
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...