Overloading Comparison Operators (__eq__, __lt__)

Medium Magic Methods & Operator Overloading
Solve in Playground →

Problem Statement

Create a `Student` class with `name` and `score`. Overload `__eq__` (equality) and `__lt__` (less than) based on the `score` attribute. Read data for two students. Print the boolean evaluation of `student1 == student2` and `student1 < student2` on separate lines.

Input Format

Two lines. Each line contains a name and an integer score separated by a space.

Output Format

Print True/False for equality, then True/False for strictly less than.

Constraints

None

Sample Input

Alice 85
Bob 90

Sample Output

Equal: False
Less: True

Explanation

Overloading rich comparison methods allows your objects to be natively compared and sorted using standard Python operators.

Starter Code

class Student:
    # Define __init__, __eq__, and __lt__
    pass

if __name__ == '__main__':
    # Read input, instantiate students, print comparisons
    pass

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used