-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPython Lab 2
61 lines (45 loc) · 1.15 KB
/
Python Lab 2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# This is Deven Bibikar starting Python Lab 2
# Deven Bibikar, Code Labs
#
def heading(name):
print()
print("*"*42)
print("Python Lab 002")
print('Code by', name)
print("*"*42)
heading('Deven')
#Functions listed here
def squarePerimeter(s):
return 4*s
def hexagonPerimeter(s):
return 6*s
def rectanglePerimeter(l,w):
return (l+w)*2
def circleCircumference(r,p):
return 2*r*p
def squareArea(s):
return s**2
def rectangleArea(l,w):
return l*w
def circleArea(r,p):
return p*(r**2)
def cubeVolume(s):
return s**3
def sphereVolume(r,p):
return (4 * p * (r**3))/3
#Preliminary Definitions
side = 4.0
length = 5.0
width = 6.0
radius = 10
pi = 3.14159
#Printing the material!
print("SQUARE PERIMETER: ",squarePerimeter(side))
print("HEXAGON PERIMETER: ",hexagonPerimeter(side))
print("RECTANGLE PERIMETER: ",rectanglePerimeter(length,width))
print("CIRCLE CIRCUMFERENCE: ",circleCircumference(radius,pi))
print("SQUARE AREA: ",squareArea(side))
print("RECTANGLE AREA: ",rectangleArea(length,width))
print("CIRCLE AREA: ",circleArea(radius,pi))
print("CUBE VOLUME: ",cubeVolume(side))
print("SPHERE VOLUME: ",sphereVolume(radius,pi))