Immutable Dataclasses (frozen=True)

Medium Modern Python OOP Features
Solve in Playground →

Problem Statement

Create a `Config` dataclass with an integer `timeout`. Make the class immutable by setting `frozen=True`. Inside a `try` block, attempt to modify the `timeout` to 100. Catch `dataclasses.FrozenInstanceError` and print ‘Immutable’.

Input Format

A single integer.

Output Format

Print 'Immutable'.

Constraints

None

Sample Input

30

Sample Output

Immutable

Explanation

Setting `frozen=True` makes the instances of the dataclass read-only, preventing post-initialization modifications.

Starter Code

import dataclasses
from dataclasses import dataclass

# Define the frozen Config dataclass here

if __name__ == '__main__':
    val = int(input())
    # Instantiate, try modifying, and catch the error
    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