-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFuctions.py
More file actions
79 lines (35 loc) · 1.38 KB
/
Fuctions.py
File metadata and controls
79 lines (35 loc) · 1.38 KB
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
73
74
75
#!/usr/bin/env python
# coding: utf-8
# # Functions
# ## - Functions are useful chunks of code that allow us to encapsulate a task.
# ## * Encapsulation is a way to carry out a whole series of steps with one simple command.
# ## - Functions are also used in to help organzie and optimize code.
# In[5]:
# Defining Functions
def cylinder_volume(height, radius):
pi = 3.14159
return height * pi * radius ** 2
cylinder_volume(10, 3)
# ## with no arguments
# In[10]:
def print_greeting():
print('Hello World!') # no return but still a valid function
# ## Local Variable
# ### - It can be only used within the body of a function
# In[ ]:
# ## Return Keyword
# ### Used to give back an output value when the function is called
# ### - If there is no return statement, the function returns None.
# ### - The value of the expresssion that follows return is the output of the function.
# In[ ]:
volume = height * pi * radius ** 2
return volume
# ## Print as a function
# ### - Print provides output to the console while return provides the value that you can store and work with and code later.
# In[ ]:
# ## Variable Scope
# ### - The parts of a program that a variable can be referenced, or used, from.
# In[ ]:
# ## Docstring (Documentation String)
# ### - A type of comment used to explain the purpose of a function and how it should be used.
# In[ ]: