Emulating Method Overloading via Default Arguments

Medium Polymorphism & Duck Typing
Solve in Playground →

Problem Statement

Python does not support traditional method overloading (defining multiple methods with the same name). Emulate it in a `Greeter` class using a default parameter. Define `greet(self, name=None)`. If `name` is None, print ‘Hello World’. Otherwise, print ‘Hello [name]’.

Input Format

A string name, or the exact word 'NONE' to simulate no argument.

Output Format

Print the appropriate greeting.

Constraints

None

Sample Input

Alice

Sample Output

Hello Alice

Explanation

Default arguments serve as Python's primary way of implementing polymorphic method signatures that accept varying amounts of data.

Starter Code

class Greeter:
    # Define greet method with default argument
    pass

if __name__ == '__main__':
    val = input().strip()
    g = Greeter()
    if val == 'NONE':
        # Call without arg
        pass
    else:
        # Call with arg
        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