Python Mastery Quiz

10:00

Collections, strings, regex, files, generators and decorators. · 10 questions

Question 1 of 10
What does `sorted([3, 1, 2])` return?
Question 2 of 10
Which module provides `Counter` and `defaultdict`?
Question 3 of 10
Which keyword turns a function into a generator?
Question 4 of 10
With `from pathlib import Path`, what is `Path('data/sales.csv').stem`?
Question 5 of 10
What does this print?
import re
print(re.findall(r'\d+', 'Order 12 costs 450 rupees'))
Question 6 of 10
Why should CSV files be opened with `newline=''` when using the csv module?
Question 7 of 10
What is printed?
gen = (x * 2 for x in range(3))
print(sum(gen), sum(gen))
Question 8 of 10
Which `json.dumps` argument keeps Hindi text readable instead of `\u` escapes?
Question 9 of 10
Why use `functools.wraps` inside a decorator?
Question 10 of 10
What does this print?
def add(item, bucket=[]):
    bucket.append(item)
    return bucket
add(1)
print(add(2))