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
+52Lines changed: 52 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -164,6 +164,8 @@ If the passed iterators have different lengths, the iterator with the least item
164
164
165
165
zip can also work with **lists**
166
166
167
+
__Syntax:__`zip(iterator1, iterator2, iterator3 ...) -> zip object`
168
+
167
169
```
168
170
a = ("John", "Charles", "Mike")
169
171
b = ("Jenny", "Christy", "Monica", "Vicky")
@@ -176,3 +178,53 @@ print(tuple(x))
176
178
# prints (('John', 'Jenny'), ('Charles', 'Christy'), ('Mike', 'Monica'))
177
179
178
180
```
181
+
#### 11. Given the first and last names of all employees in your firm, what data type will you use to store it?
182
+
183
+
#### 12.What does the function `range()` do? <br>
184
+
The range() function is used to generate a sequence of numbers over time. <br>
185
+
At its simplest, it accepts an integer and returns a `range` object (a type of iterable) <br>
186
+
187
+
__Syntax:__`range([start,] stop [, step]) -> range object`
188
+
189
+
Paramter | Description |
190
+
--- | --- |
191
+
`start`(optional) | Starting point of the sequence. It defaults to 0. |
192
+
`stop` (required) | Endpoint of the sequence. This item will not be included in the sequence. |
193
+
`step` (optional) | Step size of the sequence. It defaults to `1`.|
194
+
195
+
```
196
+
>>>
197
+
>>> range(5, 10)
198
+
range(5, 10)
199
+
>>>
200
+
>>> list(range(5, 10))
201
+
[5, 6, 7, 8, 9]
202
+
>>>
203
+
```
204
+
205
+
When `range()` is called with a single argument it generates a sequence of numbers from `0` upto the argument specified __(but not including it)__. That's why the number `5` is not included in the sequence.
206
+
207
+
Here the `range()` function is called with a `step` argument of `3`, so it will return __every third element__ from `1` to `20` (off course not including 20).
208
+
209
+
```
210
+
>>>
211
+
>>> range(1, 20, 3)
212
+
range(1, 20, 3)
213
+
>>>
214
+
>>>
215
+
>>> list(range(1, 20, 3))
216
+
[1, 4, 7, 10, 13, 16, 19]
217
+
>>>
218
+
```
219
+
220
+
You can also use the step argument to count backwards. `step` becomes a negative number in that case
0 commit comments