Destructor: The __del__ method

Medium Object Lifecycle & Constructors
Solve in Playground →

Problem Statement

Define a `Temporary` class. Its `__init__` should print ‘Created’. Its `__del__` method should print ‘Destroyed’. Instantiate the object and immediately delete it using `del`.

Input Format

None

Output Format

Print the lifecycle messages separated by a line break.

Constraints

None

Sample Output

Created
Destroyed

Explanation

The __del__ method is called when an object is about to be destroyed, either manually via del or automatically by the garbage collector.

Starter Code

class Temporary:
    # Write __init__ and __del__ here
    pass

if __name__ == '__main__':
    # Instantiate and delete
    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