Quiz Created Jan 5, 2026

Python Output Prediction Quiz: Expert-Level Mastery

Abdulla Fajal 8 Questions ~8 min 0 Participants

About this Quiz

This quiz is designed for advanced Python engineers, technical leads, and interview panels.

Questions focus on runtime behavior, lazy evaluation, memory references, descriptor protocol, MRO resolution, async execution, hashing rules, and CPython implementation details.

Not suitable for beginners.

Q1 / 8

Multiple Choice

Descriptor vs Instance Attribute

class Descriptor:
    def __get__(self, obj, objtype):
        return 100

class A:
    x = Descriptor()

a = A()
a.x = 50
print(a.x)

Q2 / 8

Multiple Choice

Late Binding in Closures

funcs = []

for i in range(3):
    funcs.append(lambda: i)

print([f() for f in funcs])

Q3 / 8

Multiple Choice

MRO Resolution Order

class A:
    def show(self):
        print("A")

class B(A):
    def show(self):
        print("B")

class C(A):
    def show(self):
        print("C")

class D(B, C):
    pass

D().show()

Q4 / 8

Multiple Choice

Mutable Default + Generator

def f(x, cache=[]):
    cache.append(x)
    yield sum(cache)

g1 = f(1)
g2 = f(2)

print(next(g1), next(g2))

Q5 / 8

Multiple Choice

Hashing & Mutability

d = {}
x = (1, [2, 3])
d[x] = "value"
print(d)

Q6 / 8

Multiple Choice

__slots__ vs __dict__

class A:
    __slots__ = ('x',)

a = A()
a.x = 10
a.y = 20
print(a.x)

Q7 / 8

Multiple Choice

Async Execution Order

import asyncio

async def main():
    print(1)
    await asyncio.sleep(0)
    print(2)

asyncio.run(main())

Q8 / 8

Multiple Choice

Metaclass Execution Timing

class Meta(type):
    def __new__(cls, name, bases, dct):
        print(name)
        return super().__new__(cls, name, bases, dct)

class A(metaclass=Meta):
    pass

class B(A):
    pass
Previous
End of questions

Authentication Required

You need to be logged in to attempt this quiz