Python Quiz

431. What is the output of:

print([i for i in range(3)][-1])
432. Which of these is the correct syntax to check if a class is a subclass of another?
433. What is the result of this code?

x = (1,)
print(type(x))
434. What will this print?

def f():
    yield from range(3)
print(list(f()))
435. Which one is **not** a valid way to merge two dictionaries in Python 3.9+?
436. What is the output of:

print({i: i*i for i in range(3)})
437. What is the main use of the `__init__` method in a class?
438. What will be printed?

x = [1, 2, 3]
print(id(x) == id(x[:]))
439. Which of the following statements about `@classmethod` is true?
440. Which of the following is true about Python's `with` statement?

Explore Programming Topics