## Code here
import math

(-4 + math.sqrt(4**2 - 4*1*3))/(2*1)

"""
Explanation: Functions
Making reusable blocks of code.
Starting point:
In this exercise, we're going to calculate one of the roots from the quadratic formula:
$r_{p} = \frac{-b + \sqrt{b^{2} - 4ac}}{2a}$
Determine $r_{p}$ for $a = 1$, $b=4$, and $c=3$.
End of explanation
"""


## Code here 

# gonna make this saner
a = 2
b = 8
c = 1

(-b + math.sqrt(b**2 - 4*a*c))/(2*a)




"""
Explanation: What about for $a = 2$, $b = 8$, and $c = 1$?
End of explanation
"""


def square(x):
    """
    This function will square x.
    """
    
    return x*x

s = square(5)

help(square)

"""
Explanation: Functions:

Code can be organized into functions.  
Functions allow you to wrap a piece of code and use it over and over. 
Makes code reusable
Avoid having to re-type the same code (each time, maybe making an error)

Observe how this function works.
End of explanation
"""


import math

def hypotenuse(y,theta):
    """
    Return a hypotenuse given y and theta in radians.
    """
    
    return math.sin(theta)*y
    

h = hypotenuse(1,math.pi/2)

print(h)
    

"""
Explanation: Observe how this function works.
End of explanation
"""


def some_function(ARGUMENT):
    """
    Print out ARGUMENT.
    """
    return 1
    
    print(ARGUMENT)
    
some_function(10)
some_function("test")

"""
Explanation: Summarize:
What is the syntax for defining a function?
```python
def FUNCTION_NAME(ARGUMENT_1,ARGUMENT_2,...,ARGUMENT_N):
    """
    Description of function.
    """
do_stuff
do_other_stuff
do_more_stuff

return VALUE_1, VALUE_2, ... VALUE_N

```
How do you get information into a function?
End of explanation
"""


def some_function(a):
    """
    print out a
    """
    print(a)

def some_function(a,b):
    """
    print out a and b
    """
    print(a,b)

"""
Explanation: Summarize
How do you get information into the function?
You get information into the function via arguments defined in the function name.
Modify
Alter the code below so it takes two arguments (a and b) and prints out both of them.
End of explanation
"""


def some_function(a,b=5,c=7):
    """
    Print a and b.
    """
    
    print(a,b,c)
    
some_function(1,c=2)
some_function(1,2)
some_function(a=5,b=4)

"""
Explanation: Predict
What does b=5 let you do?
End of explanation
"""


def some_function(a):
    """
    Multiply a by 5.
    """
    
    return a*5

print(some_function(2))
print(some_function(80.5))

x = some_function(5)
print(x)

"""
Explanation: b=5 allows you to define a default value for the argument.
How do you get information out of a function?
End of explanation
"""


def some_function(a,b):
    """
    Sum up a and b.
    """
    
    v = a + b
    
    return v

v = some_function(1,2)

print(v)

def some_function(a,b):
    """
    Sum up a and b.
    """
    
    v = a + b
    
    return v

"""
Explanation: Summarize
How do you get information out of the function?
By putting return at the end of a function, you can capture output.
Modify
Alter the program below so it returns the calculated value.
End of explanation
"""


def some_function(a):
    """
    Multiply a by 5 and 2.
    """
    
    return a*5, a*2

x, y = some_function(5)

print(x)

"""
Explanation: To return multiple values, use commas:
End of explanation
"""


## Code here

def get_root(a,b,c):

    return (-b + math.sqrt(b**2 - 4*a*c))/(2*a)

print(get_root(1,4,3))
print(get_root(2,8,1))

"""
Explanation: Implement
Write a function that uses the quadratic equation to find both roots of a polynomial for any $a$, $b$, and $c$.
End of explanation
"""


