Interface using ABC: Strict contracts

Medium Abstraction & Interfaces
Solve in Playground →

Problem Statement

Python does not have a strict `interface` keyword. Emulate one by creating an `IDataSource` ABC where *every* method (`connect`, `read`, `disconnect`) is abstract. Implement a `SQLDatabase` class fulfilling the contract. Print ‘SQL Connected’ in the connect method.

Input Format

None

Output Format

Print 'SQL Connected'.

Constraints

None

Sample Output

SQL Connected

Explanation

An interface is purely a contract defining what a class must do, containing absolutely zero concrete implementation.

Starter Code

import abc

class IDataSource(abc.ABC):
    # Define abstract connect, read, and disconnect
    pass

class SQLDatabase(IDataSource):
    # Implement the interface
    pass

if __name__ == '__main__':
    db = SQLDatabase()
    db.connect()

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