Python Dataclasses & Enums क्विज़

This Python quiz covers @dataclass and the enum module, two standard library tools that remove a lot of boilerplate. You will predict the generated __repr__ and __eq__, avoid the mutable default trap, and work with enum names, values and auto().

मीडियम 10 सवाल ~6 मिनट पास होने के लिए 80% Python 3.12

मोड चुनें

आप गेस्ट के तौर पर खेल रहे हैं: XP और streak सेव रखने के लिए साइन इन करें।

सैंपल सवाल

सवाल 1 / 10

What does this print?

from dataclasses import dataclass

@dataclass
class Point:
    x: int
    y: int = 0

print(Point(1))
जवाब दिखाएं

C. Point(x=1, y=0) @dataclass writes __init__ and __repr__ from the annotated fields. The repr shows each field by name, and y uses its default 0.

इस क्विज़ में क्या है

  • What @dataclass generates for you
  • Defaults, field(default_factory=...) and field order
  • frozen=True and order=True
  • Enum members, .name, .value and lookup by value
  • auto() and comparing enums

अक्सर पूछे जाने वाले सवाल

क्या अकाउंट ज़रूरी है?

नहीं। कोई भी खेल सकता है। XP, streak, badge और हिस्ट्री सेव रखने के लिए साइन इन करें।

कौन-सा Python वर्ज़न?

Python 3.12। आउटपुट वाले हर सवाल को कोड रन करके जांचा गया है।

क्या मैं इसे दोबारा दे सकता हूं?

हां। आपका बेस्ट स्कोर सेव रहता है, और हर बार सवाल और जवाब शफ़ल होते हैं।