Skip to content

Commit 7810cb6

Browse files
authored
Update README.md
1 parent 45058d8 commit 7810cb6

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

README.md

+29-27
Original file line numberDiff line numberDiff line change
@@ -78,44 +78,46 @@ result = add(a, b)
7878
7979
## Questions
8080
81-
1. Write a function which returns max of 2 numbers. We can use if, elif and else, right?
81+
1. Write a function which returns max of 2 numbers. We can use if, elif and else, right?
8282
2. Find the output - Concept of local and global variables
83-
```
84-
a = 60
85-
def func(z):
83+
```
84+
a = 60
85+
def func(z):
8686
print("z = ", z)
8787
a = 2
8888
print('Changed local a to', a)
89-
func(a)
90-
print('Global a is still', a)
91-
```
92-
3. What is the use of id(), print() function in python? You know the interpreter trick!
93-
4. What's the output:
89+
func(a)
90+
print('Global a is still', a)
91+
```
9492
95-
```
96-
def cube(x):
93+
3. What is the use of id(), print() function in python? You know the interpreter trick!
94+
4. What's the output:
95+
96+
```
97+
def cube(x):
9798
return x * x * x
9899

99-
x = cube(3)
100-
print x
101-
```
102-
5. Lets find the output , again! :smiley:
103-
```
104-
def foo(k):
100+
x = cube(3)
101+
print x
102+
```
103+
5. Lets find the output , again! :smiley:
104+
```
105+
def foo(k):
105106
k[0] = 1
106-
q = [0]
107-
foo(q)
108-
print(q)
109-
```
110-
6. Try this, find output?
111-
```
112-
def foo(i, x=[]):
107+
108+
q = [0]
109+
foo(q)
110+
print(q)
111+
```
112+
6. Try this, find output?
113+
```
114+
def foo(i, x=[]):
113115
x.append(x.append(i))
114116
return x
115-
for i in range(3):
117+
for i in range(3):
116118
y = foo(i)
117-
print(y)
118-
```
119+
print(y)
120+
```
119121
120122
- The trick for solving 'find the output' questions is to NOT think how the program wants to you to think. DON'T proceed with any notion of how that program is *supposed* to work, find out how that program will *exactly* work.
121123

0 commit comments

Comments
 (0)