-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvariable_scope.py
More file actions
58 lines (51 loc) · 874 Bytes
/
variable_scope.py
File metadata and controls
58 lines (51 loc) · 874 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
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
##############################
a = 10
# print(a)
def fub():
a = 10
print(a + 10)
# fub()
# print(a)
######################################
# a = 1
# print(id(a))
# def fun():
# global a
# a = a + 1
# print(a)
#
# # fun()
# # print(a)
# #####################################
#
# def fun():
# global b
# b = 20
# # fun()
# # print(b)
####################################################
# def spam():
# c = 10
# def wrapper():
# b = 20
# nonlocal c
# c += 10
# print(c)
# wrapper()
####################################
l = [1, 2, 3, 4]
l1 = []
def square():
for i in l:
l1.append(i**2)
print(l1)
square()
print(l1)
s = ""
string_ = "hai"
def rev(x):
global s
for i in x:
s = i + s
print(s)
rev(string_)