Write a python program Write a code that finds the root of a second order polynomial, y =ax^2+bx+c. Use a list as the input argument for the function. Generate a text file to be called for all code.
Added by Christopher O.
Step 1
def find_roots(coefficients): a = coefficients[0] b = coefficients[1] c = coefficients[2] discriminant = b**2 - 4*a*c if discriminant < 0: return "No real roots" elif discriminant == 0: root = -b/(2*a) return root Show more…
Show all steps
Your feedback will help us improve your experience
Dominador Tan and 63 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
In Python: Write a program that solves for roots of quadratic equations (ones of the form ax^2 + bx + c = 0). Compute/return the roots of the quadratic equation with the given integer coefficients a, b, and c.
Samuel G.
2. Create a function that, given a basis B and a vector [x]B, computes the vector x. Use functions from numpy, scipy, and/or sympy. Create a function comment header that summarizes your approach. In the same file, compute the the vector x given B and [x]B below and print the result. Save your code as problem2.py.
Vincenzo Z.
a) Write a Python program to create function calculation() such that it can accept two variables and calculate addition and subtraction. Also, it must return both addition and subtraction in a single return call. b) Write a Python program to iterate the first 10 numbers and in each iteration, print the sum of the current and previous number.
Willis J.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD