Mixing Concrete and Abstract Methods

Medium Abstraction & Interfaces
Solve in Playground →

Problem Statement

Create an abstract class `Appliance`. Define an abstract method `turn_on()`. Define a concrete method `plug_in()` that prints ‘Plugged into wall’. Subclass `Toaster` implementing `turn_on()` to print ‘Heating’. Call both methods on a `Toaster` instance.

Input Format

None

Output Format

Print the messages sequentially.

Constraints

None

Sample Output

Plugged into wall
Heating

Explanation

Abstract Base Classes can provide shared utility logic (concrete methods) alongside strict contracts (abstract methods).

Starter Code

import abc

class Appliance(abc.ABC):
    # Define abstract turn_on and concrete plug_in
    pass

class Toaster(Appliance):
    # Implement turn_on
    pass

if __name__ == '__main__':
    t = Toaster()
    t.plug_in()
    t.turn_on()

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