Default Parameter Values in Constructors

Easy Object Lifecycle & Constructors
Solve in Playground →

Problem Statement

Create a `Greeting` class. Its `__init__` method should accept a `name` parameter that defaults to ‘Guest’. It should print ‘Hello, [name]’.

Input Format

A single string (may be empty).

Output Format

Print the greeting message.

Constraints

None

Sample Input

Alice

Sample Output

Hello, Alice

Explanation

Default parameters in __init__ allow objects to be created with or without providing certain arguments.

Starter Code

class Greeting:
    # Write your __init__ with a default parameter here
    pass

if __name__ == '__main__':
    name = input().strip()
    if name:
        # Instantiate with name
        pass
    else:
        # Instantiate without arguments
        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