There was an error while loading. Please reload this page.
1 parent 5ff07f9 commit 22b7837Copy full SHA for 22b7837
Scopes/scopes.py
@@ -0,0 +1,48 @@
1
+# Scopes And Closure
2
+
3
+username = 'Maaz Khan'
4
5
6
+def func():
7
+ # username = 'BsAi'
8
+ print(username)
9
10
+print(username)
11
+func()
12
13
14
+x = 99
15
16
+# def func2(y):
17
+# z = x + y
18
+# return z
19
20
+# result = func2(4)
21
+# print(result)
22
23
+# def func3():
24
+# global x
25
+# x = 12
26
27
+# func3()
28
+# print(x)
29
30
+def f1():
31
+ x = 88
32
+ def f2():
33
+ print(x)
34
+ return f2
35
+myResult = f1()
36
+myResult()
37
38
39
+def bsAi(num):
40
+ def mainFunc(x):
41
+ return x ** num
42
+ return mainFunc
43
44
+g = bsAi(2)
45
+f = bsAi(4)
46
47
+print(g(2))
48
+print(g(4))
0 commit comments