![kat9490](/avatars/36065.jpg)
kat9490
11.10.2019 •
Computers and Technology
'''
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()
Solved
Show answers
More tips
- H Health and Medicine What is Autism? Understanding the Basics of This Neurodevelopmental Disorder...
- F Food and Cooking The Most Delicious and Simple Fish in Batter Recipe...
- S Society and Politics 10 Tips for Boosting Your Self-Esteem...
- F Food and Cooking Which Calamari Salad is the Most Delicious?...
- H Health and Medicine Mercury Thermometer Danger: What to do when a thermometer breaks?...
- S Style and Beauty How to braid friendship bracelets?...
- F Food and Cooking Delight for Gourmets: How to Prepare Liver Pate...
- C Computers and Internet How to Learn to Type Fast?...
- H Health and Medicine Angina: Causes, Symptoms, and Treatment...
- D Dating, Love, Relationships How to Overcome Jealousy: Tips and Tricks...
Answers on questions: Computers and Technology
- C Computers and Technology Please help! 15pts What is the exact meaning of keyword final in the following variable declaration: final double pi = 3.1416;...
- C Computers and Technology When explaining cognitive development to her class, Dr. Calderon refers to memory as being stored in networks and compares memory to how computers analyze and store data....
- C Computers and Technology John Sgromolo works for the 20th-largest accounting firm in the United States, but he s not an accountant. He works with hard drives and various other types of computer...
- C Computers and Technology B)Consider FA (1) and FA (2). Let L1be the language accepted by FA (1), and let L2be the language accepted by FA (2).(a) Using the algorithm of Kleene’s theorem, Lemma 3,...
- C Computers and Technology The volume of the software as a service (saas) market is growing and predicted to reach one-fourth of the software market. what are the technological developments that cause...
- C Computers and Technology Achief information security officer (ciso) needs to establish a kri for a particular system. the system holds archives of contracts that are no longer in use. the contracts...
- M Mathematics A is between B and C. BA = 11, BC = 20 find AC...
- E English What are five important points that the author makes in the Prologue of Strange Pilgrims?...
- H History How did ancient Egyptians view their pharaohs?...
- P Physics How many elements in oxygen gas? PLEASE ANSWER!...
Ответ:
answer:
the lifelong kindergarten group
explanation:
scratch is a free educational programming language that was developed by the lifelong kindergarten group at the massachusetts institute of technology (mit) with over 40 million registered users and 42 million shared projects.