Inheriting with Slots

Hard Modern Python OOP Features PRO
🔒 Login to Unlock

Problem Statement

Create a `Base` class with `__slots__ = (‘a’,)` and a `Child` class inheriting from `Base` with `__slots__ = (‘b’,)`. Write their `__init__` methods to accept and set these attributes. Print ‘A: [a], B: [b]’.

Input Format

Two space-separated integers.

Output Format

Print the formatted values.

Constraints

None

Sample Input

5 10

Sample Output

A: 5, B: 10

Explanation

When inheriting classes with slots, you must explicitly declare slots in the child class to maintain memory optimizations, avoiding the creation of an instance dictionary.

Starter Code

class Base:
    # Define __slots__ and __init__
    pass

class Child(Base):
    # Define __slots__ and __init__ calling super()
    pass

if __name__ == '__main__':
    a, b = map(int, input().split())
    # Instantiate Child and print
    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