โœ•
โœ๏ธ Content byMd. Rakibul Islam
๐ŸŽฏ
MCQ
Multiple Choice ยท 8 questions
1Hardconcurrencyโฑ 45s

What is the Global Interpreter Lock (GIL) in CPython and what does it prevent?

โ–ผ
2Harddecoratorsโฑ 45s

What is the output of this decorator example?

โ–ผ
python
def decorator(fn):
    def wrapper(*args, **kwargs):
        print('before')
        result = fn(*args, **kwargs)
        print('after')
        return result
    return wrapper

@decorator
def greet(name):
    print(f'Hello, {name}')
    return 'done'

result = greet('Alice')
3HardOOPโฑ 40s

What is the difference between @staticmethod and @classmethod in Python?

โ–ผ
4Hardgeneratorsโฑ 45s

What are Python generators and what advantage do they have over regular functions that return lists?

โ–ผ
python
def count_up(n):
    i = 0
    while i < n:
        yield i
        i += 1

gen = count_up(1_000_000)
print(next(gen), next(gen))
5Hardmetaclassesโฑ 45s

What is a metaclass in Python and when would you use one?

โ–ผ
6Hardasyncโฑ 45s

What is the purpose of asyncio in Python and what concurrency model does it use?

โ–ผ
7Hardfunctionsโฑ 60s

What is the output of this code about Python's default mutable argument pitfall?

โ–ผ
python
def append_to(element, lst=[]):
    lst.append(element)
    return lst

print(append_to(1))
print(append_to(2))
print(append_to(3, []))
8Harddunder methodsโฑ 40s

What is the difference between __str__ and __repr__ in Python?

โ–ผ
Python MCQ Interview Questions โ€” All Levels | UyTech