Determine $r_{p}$ for $a = 1$, $b=4$, and $c=3$.
In [ ]:
## Code here
What about for $a = 2$, $b = 8$, and $c = 1$?
In [ ]:
## Code here
In [ ]:
def square(x):
"""
This function will square x.
"""
return x*x
s = square(5)
print(s)
In [ ]:
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)
In [ ]:
def some_function(ARGUMENT):
"""
Print out ARGUMENT.
"""
return 1
print(ARGUMENT)
some_function(10)
some_function("test")
In [ ]:
def some_function(a):
"""
print out a
"""
print(a)
In [ ]:
def some_function(a,b):
"""
print out a and b
"""
print(a,b)
In [ ]:
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)
b=5 allows you to define a default value for the argument.
In [ ]:
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)
In [ ]:
def some_function(a,b):
"""
Sum up a and b.
"""
v = a + b
return v
v = some_function(1,2)
print(v)
In [ ]:
def some_function(a,b):
"""
Sum up a and b.
"""
v = a + b
return v
To return multiple values, use commas:
In [ ]:
def some_function(a):
"""
Multiply a by 5 and 2.
"""
return a*5, a*2
x, y = some_function(5)
print(x)
In [ ]:
## Code here