-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhackerrank-exampleScope.py
More file actions
34 lines (26 loc) · 917 Bytes
/
hackerrank-exampleScope.py
File metadata and controls
34 lines (26 loc) · 917 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
class Scopetiando:
def __init__(self):
self.b = True
self.x = 88
def Scope(self):
self.d = 9.0
# print(example(9))
# classVariable()
def example(self, x):
print("----- example(x):\n",
"Initial value of Local Variable `x`: ", x, "\n")
x = 4.4
print("New value of Local Variable `x`: ", x, "\n")
for i in range(4):
b = i + 4
print("For Loop 1 in example(double x):\n", "Local Variable `b` (local to loop): ", i, "\n",
"Local Variable `i` (local to loop): ", b, "\n",
"Local Variable `x` (method parameter): ", x, "\n")
def classVariable(self):
print("----- classVariable():\n",
"Instance Variable `b`: ", self.b, "\n"
"Instance Variable `x`: ", self.x)
s = Scopetiando()
s.Scope()
s.example(9)
s.classVariable()