subject
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()

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 12:50
You have just been hired as an information security engineer for a large, multi-international corporation. unfortunately, your company has suffered multiple security breaches that have threatened customers' trust in the fact that their confidential data and financial assets are private and secured. credit-card information was compromised by an attack that infiltrated the network through a vulnerable wireless connection within the organization. the other breach was an inside job where personal data was stolen because of weak access-control policies within the organization that allowed an unauthorized individual access to valuable data. your job is to develop a risk-management policy that addresses the two security breaches and how to mitigate these risks.requirementswrite a brief description of the case study. it requires two to three pages, based upon the apa style of writing. use transition words; a thesis statement; an introduction, body, and conclusion; and a reference page with at least two references. use a double-spaced, arial font, size 12.
Answers: 1
question
Computers and Technology, 23.06.2019 04:40
The narrative structure of the popular movies can be broken down into
Answers: 3
question
Computers and Technology, 23.06.2019 08:30
Based on your knowledge of a good network, describe what you think is a perfect network would be. what kind of information and resources could users share on this network. what would the network administrator do? what kind of communication would be used?
Answers: 1
question
Computers and Technology, 23.06.2019 11:00
What are the possible consequences of computer hacking? what is computer piracy? describe some examples. what are the effects of computer piracy? what are the possible consequences of computer piracy? what is intentional virus setting? describe some examples. what are the effects of intentional virus setting? what are the possible consequences of intentional virus setting? what is invasion of privacy? describe some examples. what are the effects of invasion of privacy? what are the possible consequences of invasion of privacy? what is an acceptable use policy and what is the purpose of the acceptable use policy what is intellectual property and how can you use it?
Answers: 1
You know the right answer?
'''
math_funcs

complete the following functions. you must, must, must add:
...
Questions
question
Mathematics, 07.10.2020 23:01
Questions on the website: 13722363