Computers and Technology

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

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 18:00, mterzic1
Assume that you have an array of integers named a. which of these code segments print the same results? int i = 1; while(i < a. length) { system. out. println(a[i]); i++; } int i; for (i = 0; i < a. length; i++) { system. out. println(a[i]); } for (int i : a) { system. out. println(i); } i and ii only ii and iii only i and iii only all three print the same results. all three print different results.
Answers: 3
image
Computers and Technology, 24.06.2019 08:30, trashellyoung
Why might you choose to create a functional resume
Answers: 1
image
Computers and Technology, 24.06.2019 10:00, alexapacheco012
What did i do wrong with this const discord = require('discord. js'); var bot = new discord. client(); const token = 'ntm3mjcxmtu1mjg3ote2ntq2.dyogew. dpfiwfpuifzuzvifop-csuxasnm' const prefix = "! " bot. registry. registergroup('simple', 'simple'); bot. registry. registerdefaults(); bot. registry. + '/commands'); bot. on('message', message => { if(message. content == 'hi! ') { message. channel. send ('@everyone sup, how is @everyone day going'); } if(message. content == 'h3lp') { message. channel. send ('dose not have any commands yet'); } bot. on('ready', function() { console. log("ready") }); bot. login(token);
Answers: 1
image
Computers and Technology, 24.06.2019 13:00, brusawerin5969
Refer to the figure and match the theorem that supports the statement.1.if chords are =, then arcs are =.if bc = de, then arc bc = arc de2.if arcs are =, then chords are =.if arc bc = arc de, then bc = de3.diameters perpen
Answers: 3
Do you know the correct answer?
Hlp

'''
math_funcs

complete the following functions. you must, must,...

Questions in other subjects:

Konu
Mathematics, 31.03.2021 21:40
Konu
Mathematics, 31.03.2021 21:40
Konu
Biology, 31.03.2021 21:40