-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.py
72 lines (56 loc) · 1.56 KB
/
functions.py
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
62
63
64
65
66
67
68
69
70
71
72
Picture of Python Programming - functions
#Using functions
# Basic function that prints a statement
def hello():
print ("Hello world!")
# Call the function
hello()
print("===================")
# Function that returns a value
def whatispi():
return 3.14159
# Call the function
print ("Pi is:", whatispi() )
print("===================")
# Function that calculates using a formula
def area(length, width):
area = length * width
print ("The area is:", area)
# Call the function with arguments
area(9,8)
print("===================")
# Function that calculates but provides more information
def areawithinfo(length, width):
area = length * width
print ("Length is:", length)
print ("Width is:", width)
print ("Total area is:", area)
# Call the function with arguments
areawithinfo(9,8)
print("===================")
# Function that returns a value
def areareturn(length, width):
area = length * width
return area
# Call a function with arguments.
# Then take the return value and place it into a variable
computerroom = areareturn (9,8)
print ("The area of the computer room is:", computerroom)
print ("================")
# Calling 2 functions
def roomarea(length, width):
area = length*width
return area
def roomvolume(area, height):
volume = area*height
return volume
area = roomarea(9,8)
finalvolume = roomvolume(area,10)
print ("The volume is: ", finalvolume)
print ("================")
# Function calling other functions
def callother(length, width):
hello()
whatispi()
area(length, width)
callother (9, 10)