help with math fuctions
somansa (0)

I have problem to understand this question:

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

def circle_area(radius):

def sphere_surface_area(radius):

def sphere_volume(radius):

if name == "main":
import doctest
doctest.testmod()

You are viewing a single comment. View All
Giothecoder (13)

What’s the problem?