How Well Do You Know Python?
Put your Python knowledge to the test and see how many correct answers you can get out of 15!
Question 1 of 15How Well Do You Know Python?
All 15 questions
- Which of the following functions is NOT part of the itertools module?count() · cycle() · repeat() · map()
- What does the itertools 'product()' function do?Generates the Cartesian product of input iterables · Generates an infinite sequence of elements · Repeats an element infinitely · Accumulates sums of elements from iterable
- Which function from itertools would you use to repeatedly generate 'ABABAB...'? count() · cycle() · repeat() · accumulate()
- What does the lambda keyword in Python do?Defines a small anonymous function · Creates a generator · Starts a multiline comment · Defines a named function
- Which of these is the syntax for defining a lambda function?lambda x: x + 1 · def lambda(x): x + 1 · lambda (x: x + 1) · def lambda x: x + 1
- What is the purpose of the 're' module?Regular expressions · Random number generation · Reading files · Handling dates and times
- Which method from the 're' module would you use to find all non-overlapping matches of a pattern in a string?search() · match() · findall() · sub()
- Which one is NOT a magic method in Python?__add__ · __init__ · __call__ · __map__
- What is threading primarily used for in Python?Speeding up computation by parallel execution · Reading and writing network sockets · Managing memory allocation · Creating GUI applications
- Which module must be imported to use Thread class in Python?threading · multiprocessing · asyncio · concurrent
- What is the main purpose of the 'map()' function?To apply a function to all items in an iterable · To filter elements from an iterable · To accumulate the results of elements in an iterable · To repeat elements of an iterable
- What will be the result of evaluating list(map(lambda x: x + 1, [1, 2, 3]))?[2, 3, 4] · [1, 2, 3] · [0, 1, 2] · [3, 4, 5]
- What kind of exception does the 'ZeroDivisionError' in Python handle?Division of a number by zero · Accessing an undefined variable · Accessing a list out of its bounds · File not found error
- Which method is called automatically when an instance of a class is created?__str__ · __init__ · __add__ · __repr__
- What does the 'finally' block do in exception handling?Executes code no matter what happens · Handles an exception if one is raised · Raises an exception · Ignores any exceptions





