+ Addition- Subtraction* Multiplication/ Division// Integer Division** Exponent% ModulusWrite a function that calculates the area of a square:
square_areasideround()round()Use the round() function to get a floating-point number rounded to the specified number of decimals.
Syntax:
The number of digits (ndigits) is optional, but we will often round number to two decimals:
round()Use the round() function to get a floating-point number rounded to the specified number of decimals.
Syntax:
Rounding is done toward the nearest even choice. What would these round to? (discuss with your group)
round()Use the round() function to get a floating-point number rounded to the specified number of decimals.
Syntax:
Rounding is done toward the nearest even choice. What would these round to:
Write a function that calculates the volume of a sphere:
sphere_volumeradius3.1415 for \(\pi\)):\[ v = {4 / 3} \cdot \pi \cdot radius^3 \]
sphere_volume(.75) should return 1.77.Write a function that calculates the area of a sphere:
sphere_arearadius3.1415 for \(\pi\)):\[ a = 4 \cdot \pi \cdot radius^2 \]
sphere_area(.75) should return 7.07.def sphere_volume(radius):
"calculates the volume of a sphere of given radius"
volume = (4 / 3) * 3.1415 * radius**3
return round(volume, 2)
def sphere_area(radius):
"calculates the area of a sphere of given radius"
area = 4 * 3.1415 * radius**2
return round(area, 2)
r = .75
v = sphere_volume(r)
a = sphere_area(r)
print(v, a)1.77 7.07
Submit your sphere volume and area solution as attendance on Gradescope.
Name your file sphere.py