Quadratic
Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
Description
In this problem, you'll write a short program to compute the result of evaluating a quadratic ax^2 + bx + c at a particular value of x.
The first four lines of your program should set up variables to hold the relevant values (a, b, c, and x). So the first four lines of your program should look like, for example:
a = 1
b = 2
c = 3
x = 0.5
Your program should print a single number representing the value associated with evaluating the quadratic speficied by a
, b
, and c
with the given value of x
.
Notes
- Python isn't picky about variable names, but our checker is. It's important that you call the variables mentioned above
a
,b
,c
, andx
, rather than giving them other names.
Submission
When you are ready, upload your Python file below:
Description
Now you'll write a program to compute the roots of the quadratic ax^2 + bx + c.
The first three lines of your program should set up variables to hold the relevant values (a, b, and c). So the first three lines of your program should look like, for example:
a = 1
b = 2
c = 3
Your program should print the roots of the polynomial specified by those variables, with one root on each line (note that this means that your program should handle the special case when a=0 by printing only a single value).
Notes
- Try simulating your code by hand for a few different values of the variables above to make sure you've got a working program. Only submit it once you've tested it, both by hand and on your own machine using Python.
- Python isn't picky about variable names, but our checker is. It's important that you call the variables mentioned above
a
,b
, andc
, rather than giving them other names. - Python really is amazing; it has built-in support for complex numbers! Try, for example, evaluating the following:
print(1+(-2)**0.5)
. You'll see Python print out its built-in representation of a complex number. Note also that Python uses a notation common in engineering: the imaginary unit \sqrt{-1} is referred to as j instead of i.
Submission
When you are ready, upload your Python file below: