forked from fenyx-it-academy/Class6-Python-Module-Week3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSphereVolume.py
More file actions
23 lines (18 loc) · 867 Bytes
/
Copy pathSphereVolume.py
File metadata and controls
23 lines (18 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Write a function sphere_volume that calculates and returns the volume of a sphere when given radius r as a parameter.
#def sphere_volume(r):
#pi = 3.14
#return print('Volume is: ', (4*pi*r**3)/3)
# Write a function sphere that calls two other functions that calculate the area of a circle sphere_area and volume of a sphere
# sphere_volume for a given radius r as a parameter. Functions sphere_area and sphere_volume are nested inside the function sphere.
# Function sphere returns both the area and the volume of the sphere. (Reproduce sphere_volume function inside function sphere.)
# Make sure to print the results.
def sphere_area(r):
pi = 3.14
area = pi*r**2
return area
def sphere_volume(r):
pi = 3.14
volume = 4/3*sphere_area(r)*r
return volume
print('Volume is : ',sphere_volume(5))
print('Area is :',sphere_area(5))