-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03-functions.py
More file actions
32 lines (25 loc) · 753 Bytes
/
03-functions.py
File metadata and controls
32 lines (25 loc) · 753 Bytes
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
globlaValue = ""
def echo(inputValue):
return inputValue+" echo " + globlaValue
def echoEdit(inputValue):
globlaValue = "Bob" #local variable
return inputValue+" Bob " + globlaValue
def echoEditGlobal(inputValue):
global globlaValue #here is using the global variable
globlaValue = "carl"
return inputValue+" carl " + globlaValue
firstValue = input("Enter a value: ")
print(echo(firstValue))
print(globlaValue)
print(echoEdit(firstValue))
print(globlaValue)
print(echoEditGlobal(firstValue))
print(globlaValue)
globlaValue = "global"
secondValue = input("Enter a value: ")
print(echo(secondValue))
print(globlaValue)
print(echoEdit(secondValue))
print(globlaValue)
print(echoEditGlobal(secondValue))
print(globlaValue)