← Quiz: Type Hints and Dataclasses: all 10 questions
Quiz: Type Hints and Dataclasses · Question 7 of 10
What does this print? (code)
What does this print?
from dataclasses import dataclass
@dataclass(order=True)
class S:
marks: int
name: str
print(max(S(80, "Ravi"), S(80, "Asha")).name)
- A.Asha
- B.Ravi
- C.80
- D.An error
Answer & explanation
Correct answer: Ravi
Marks tie, so the name decides: "Ravi" > "Asha".
Can you get the rest right without peeking?
Take the timed Quiz: Type Hints and Dataclasses quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →