ProgrammingVery hardGATE CS · Product-company placement

What is printed?

What is printed?
def register(cls):
    cls.tag = cls.__name__.lower()
    return cls
@register
class Alpha:
    tag = "none"
class Beta(Alpha):
    pass
print(Alpha.tag, Beta.tag)
  1. A. alpha alpha
  2. B. alpha beta
  3. C. none beta
  4. D. alpha none

Correct answer: A. alpha alpha

A class decorator runs once on Alpha, overwriting Alpha.tag. Beta is not decorated; it simply inherits the class attribute 'alpha'.

More Python Programming questions

Exams that ask this topic