Standard Classes vs NamedTuples

Easy Modern Python OOP Features
Solve in Playground →

Problem Statement

Use the `collections` module to create a `namedtuple` called `Color` with fields `r`, `g`, and `b`. Instantiate the `Color` object with three inputs and print it directly.

Input Format

Three space-separated integers.

Output Format

Print the default namedtuple representation.

Constraints

0 <= r, g, b <= 255

Sample Input

255 0 0

Sample Output

Color(r=255, g=0, b=0)

Explanation

NamedTuples are lightweight, immutable alternatives to full classes, preceding dataclasses in Python history.

Starter Code

from collections import namedtuple

# Define the Color namedtuple here

if __name__ == '__main__':
    r, g, b = map(int, input().split())
    # Instantiate and print
    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