Designing and Applying Mixin Classes

Medium Advanced Inheritance & MRO
Solve in Playground →

Problem Statement

Create a `LoggerMixin` with a method `log(self, msg)` that prints `[LOG] [msg]`. Create a `UserService` class that inherits from `LoggerMixin`. In the `UserService.create_user(self, name)` method, call `self.log(‘User ‘ + name + ‘ created’)`. Read a name, instantiate the service, and call `create_user`.

Input Format

A single word string representing the name.

Output Format

Print the log message.

Constraints

None

Sample Input

Alice

Sample Output

[LOG] User Alice created

Explanation

Mixins are small, focused classes designed to provide reusable utility methods to other classes via multiple inheritance without acting as standard base classes.

Starter Code

class LoggerMixin:
    # Define the log method
    pass

class UserService(LoggerMixin):
    def create_user(self, name):
        # Use self.log to log the creation
        pass

if __name__ == '__main__':
    name = input().strip()
    # Instantiate UserService and create a user
    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