You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Python_Programming_Quiz.md
+21-1Lines changed: 21 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -143,7 +143,7 @@ Operator | Description |
143
143
`**=` | Exponent and Assign |
144
144
`//=` | Floor Divide and Assign |
145
145
146
-
#### 8. What is recursion ? <br>
146
+
#### 9. What is recursion ? <br>
147
147
When a function makes a call to itself, it is termed recursion.<br>
148
148
But then, in order for it to avoid forming an infinite loop, we must have a base condition.<br>
149
149
@@ -156,3 +156,23 @@ return n*facto(n-1)
156
156
157
157
facto(4) # This will compute 4x3x2x1 = 24
158
158
```
159
+
160
+
#### 10.What does the function `zip()` do? <br>
161
+
The `zip()` function returns a `zip` object, which is an **iterator of tuples** where the first item in each passed iterator is **paired together**, and then the second item in each passed iterator are paired together etc.
162
+
163
+
If the passed iterators have different lengths, the iterator with the least items decides the length of the new iterator.
164
+
165
+
zip can also work with **lists**
166
+
167
+
```
168
+
a = ("John", "Charles", "Mike")
169
+
b = ("Jenny", "Christy", "Monica", "Vicky")
170
+
171
+
x = zip(a, b)
172
+
173
+
#use the tuple() function to display a readable version of the result:
174
+
175
+
print(tuple(x))
176
+
# prints (('John', 'Jenny'), ('Charles', 'Christy'), ('Mike', 'Monica'))
0 commit comments