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 13:30
Jane’s team is using the v-shaped model for their project. during the high-level design phase of the project, testers perform integration testing. what is the purpose of an integration test plan in the v-model of development? a. checks if the team has gathered all the requirements b. checks how the product interacts with external systems c. checks the flow of data in internal modules d. checks how the product works from the client side
Answers: 1
question
Computers and Technology, 23.06.2019 01:30
Jason works as an accountant in a department store. he needs to keep a daily record of all the invoices issued by the store. which file naming convention would him the most? a)give the file a unique name b)name the file in yymmdd format c)use descriptive name while naming the files d)use capital letters while naming the file
Answers: 3
question
Computers and Technology, 23.06.2019 03:00
Jason, samantha, ravi, sheila, and ankit are preparing for an upcoming marathon. each day of the week, they run a certain number of miles and write them into a notebook. at the end of the week, they would like to know the number of miles run each day, the total miles for the week, and average miles run each day. write a program to them analyze their data. your program must contain parallel arrays: an array to store the names of the runners and a two-dimensional array of five rows and seven columns to store the number of miles run by each runner each day. furthermore, your program must contain at least the following functions: a function to read and store the runners’ names and the numbers of miles run each day; a function to find the total miles run by each runner and the average number of miles run each day; and a function to output the results. (you may assume that the input data is stored in a file and each line of data is in the following form: runnername milesday1 milesday2 milesday3 milesday4 milesday5 milesday6 milesday7.)
Answers: 3
question
Computers and Technology, 23.06.2019 06:00
Which statement is true of web-based social media? a.they allow consumers to interact with and update content. b.they cannot be updated easily, as compared to print media. c.they are expensive to produce and maintain, as compared to print and television. d.they can exist independent of the internet.
Answers: 1
You know the right answer?
'''
math_funcs

complete the following functions. you must, must, must add:
...
Questions
Questions on the website: 13722360