Advanced Python Fundamentals for Backend Engineers
An advanced quiz to test deep understanding of Python fundamentals in backend engineering.
Questions in this quiz
10 questions on Advanced Python Fundamentals for Backend Engineers. Work through them here, then start the quiz to answer them and see your score.
1.What will be the output of the following code snippet? `print((lambda x: x**2)(5))`
- A5
- B10
- C25
- DNone
2.Which of the following statements about Python's GIL (Global Interpreter Lock) is true?
- AIt prevents multiple native threads from executing Python bytecodes at once.
- BIt is a security feature to prevent data races.
- CIt is used to manage memory allocation.
- DIt allows multiple threads to execute simultaneously.
3.What is the result of `list(map(lambda x: x*2, [1, 2, 3]))`?
- A[2, 4, 6]
- B[2, 3, 4]
- C[1, 2, 3]
- D[1, 4, 9]
4.In Python, what is the primary difference between a list and a tuple?
- ALists can only store integers, tuples can store any data type.
- BLists are mutable, tuples are immutable.
- CLists are faster than tuples.
- DLists are immutable, tuples are mutable.
5.What will be the output of `print({1, 2, 3} & {2, 3, 4})`?
- A{1, 4}
- BNone
- C{1, 2, 3, 4}
- D{2, 3}
6.Which of the following is a valid way to define a generator in Python?
- AUsing the `return` keyword in a function.
- BUsing a dictionary comprehension.
- CUsing the `yield` keyword in a function.
- DUsing a list comprehension.
7.What is the output of `print('Hello'[::-1])`?
- ANone
- BHello
- CError
- DolleH
8.Which of the following is true about Python decorators?
- AThey can only be applied to classes.
- BThey are functions that modify the behavior of another function.
- CThey are used to define class methods.
- DThey modify the arguments passed to a function.
9.What will be the output of `print([i for i in range(5) if i % 2 == 0])`?
- A[0, 1, 2, 3, 4]
- B[2, 4]
- C[1, 3]
- D[0, 2, 4]
10.What is the result of executing the code `print((lambda x, y: x + y)(3, 4))`?
- A7
- B12
- CError
- D34