subject

Hlp

'''
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 01:50
A.) generate scaffolding to create database for your application. develop all the entities identified in assignment #2. add any additional that may be identified later. b.) add data validation rules to the models that are appropriate for your application and data. c.) create links for each scaffold in the header section. part 2: application updates [30 points] a.) add two additional views to the "home" controller you created in assignment #1. b.) the two views should be named as “privacy" and "". c.) link the two newly created views in the footer section. hint: you would need to modify the “home" controller definition and create “privacy.html.erb" and “.html.erb" files in appropriate locations.
Answers: 3
question
Computers and Technology, 22.06.2019 17:00
Acase study allows a more detailed look at the life of a single subject than any other study.
Answers: 3
question
Computers and Technology, 23.06.2019 07:30
Write a program that inserts the digits of an integer into an array in originalorderfollowed by reverse order. first, promptthe user to enter a positive integer(> 0). determine the number of digits of the integer. create a dynamically allocated integer arrayof a size twice the number of digits.now insert the digits in original order which will occupy half of the array. then, insert the digits in reverse order.finally, output thedigits in thearray.use at least two functions to organize your program.
Answers: 3
question
Computers and Technology, 23.06.2019 11:00
In the context of the box model, what is the difference between a margin and a padding? a. a padding lies outside a box border, while a margin lies inside it. b. a padding lies inside a box border, while a margin lies outside it. c. a padding can be adjusted independently, while a margin depends on the size of its box. d. a padding depends on the size of its box, while a margin can be adjusted independently.
Answers: 3
You know the right answer?
Hlp

'''
math_funcs

complete the following functions. you must, must,...
Questions
question
Health, 25.06.2019 06:40