'''
math_funcs
complete the following functions. you must, must, must add:
...
![Computers and Technology](/tpl/images/cats/informatica.png)
Computers and Technology, 11.10.2019 19:10, TJxx187
'''
math_funcs
complete the following functions. you must, must, must add:
1) a doc comment in the proper location for each function that describes
the basic purpose of the function.
2) at least 5 doc test comments in each function that:
* test that the function does what it is supposed to do
* tests that it does what it's supposed to do with odd inputs
* tests "edge" cases (numbers at, just above, just below min/max, empty strings, etc.)
you must, must, must then test each of your methods by both:
1) running the "main. py" script
2) running this module directly to run the doc tests
except as noted, you can implement the functions however you like. and if your grade-school
math's out of date, google's your friend for formulas (but not for code).
challenge: use try/except blocks to avoid crashes when passing in unexpected parameters.
circle_area
return the area of a circle with a radius supplied by the parameter.
note that you must use the "pi" constant from the math module, so
use an import statement. if the radius passed is less than 1 or
greater than 1000, print "error" and return 0.
sphere_surface_area
return the surface area of a sphere with the supplied radius. slightly
different error check here: if the radius passed is less than 1 or
greater than 250, print "error" and return 0.
sphere_volume
return the volume of a sphere with the supplied radius. again, slightly
different error check here: if the radius passed is less than 1 or
greater than 100, print "error" and return 0.
'''
# import that pi constant here
from math import pi
def circle_area(radius):
area = math. pi * radius**2
if radius > 1 or > 1000:
print(error)
return 0
from math import pi
def sphere_surface_area(radius):
sa = 4 * math. pi * radius * 2
if radius < 1 or radius > 250:
print(error)
return 0
from math import pi
def sphere_volume(radius):
sv = 4 * math. pi * radius * 3
if radius < 1 or radius > 100
print(error)
return 0
if __name__ == "__main__":
import doctest
doctest. testmod()
![answer](/tpl/images/cats/otvet.png)
Answers: 3
Other questions on the subject: Computers and Technology
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 02:00, akatherine1738
What is a loop? a. a collection of function definitions at the top of a program b. a line of code that defines a variable and assigns it a value c. a program that opens the turtle graphics window d. a block of code that repeats a specific number of times
Answers: 1
Do you know the correct answer?
Questions in other subjects:
![Konu](/tpl/images/cats/mkx.png)
![Konu](/tpl/images/cats/istoriya.png)
History, 15.12.2020 21:30
![Konu](/tpl/images/cats/fr.png)
![Konu](/tpl/images/cats/mat.png)
Mathematics, 15.12.2020 21:30
![Konu](/tpl/images/cats/User.png)
![Konu](/tpl/images/cats/mat.png)
![Konu](/tpl/images/cats/mkx.png)
![Konu](/tpl/images/cats/mat.png)
Mathematics, 15.12.2020 21:30
![Konu](/tpl/images/cats/mat.png)