Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6a71298

Browse files
author
Amogh Singhal
authored
Update Python_Programming_Quiz.md
1 parent f40eccd commit 6a71298

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

‎Python_Programming_Quiz.md‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Operator | Description |
143143
`**=` | Exponent and Assign |
144144
`//=` | Floor Divide and Assign |
145145

146-
#### 8. What is recursion ? <br>
146+
#### 9. What is recursion ? <br>
147147
When a function makes a call to itself, it is termed recursion.<br>
148148
But then, in order for it to avoid forming an infinite loop, we must have a base condition.<br>
149149

@@ -156,3 +156,23 @@ return n*facto(n-1)
156156
157157
facto(4) # This will compute 4x3x2x1 = 24
158158
```
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'))
177+
178+
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /