Python Fundamental Quiz 10

Python Fundamental Quiz 10

Basic Difficult Python Quiz for New Learners

This quiz is designed to challenge new Python programmers by testing their understanding of the language beyond basic syntax. It covers advanced topics and tricky concepts such as mutable and immutable data types, default argument behavior, list comprehensions, OOP principles, generator expressions, and lambda functions. Each question will require careful reading and a deep

1 / 10

What is the output of the following code?

class A:
def __init__(self):
self.x = 1

class B(A):
pass

b = B()
print(b.x)

2 / 10

What does the following code return?

class Foo:
def __call__(self):
return 'Called!'

foo_instance = Foo()
print(foo_instance())

3 / 10

Which of the following statements about Python @staticmethod is false?

4 / 10

Which of the following is true about Python sets?

5 / 10

What does the following code return?

def foo(x=[]):
return len(x)

print(foo())

6 / 10

What does the following code do?

from functools import reduce
reduce(lambda x, y: x + y, [1, 2, 3, 4])

7 / 10

What is the result of the following code?

def foo():
yield 1
return 2

g = foo()
print(next(g))
print(next(g))

8 / 10

What will the following code output?

def f(a, b=[]):
b.append(a)
return b

print(f(1))
print(f(2))

9 / 10

Which of the following functions is used to import a module dynamically in Python?

10 / 10

What is the result of the following code?

print(list(map(lambda x: x**2, [1, 2, 3, 4])))

Your score is

The average score is 37%

0%