Property Setters with Data Validation

Medium Encapsulation & Data Hiding PRO
🔒 Login to Unlock

Problem Statement

Extend the `Weather` class. Add a `@temperature.setter` that sets `__temp`. If the input value is below absolute zero (-273), force the value to be -273. Print ‘Final Temp: [val]’.

Input Format

A single integer.

Output Format

Print the validated temperature.

Constraints

None

Sample Input

-300

Sample Output

Final Temp: -273

Explanation

Property setters allow transparent data validation whenever an attribute is reassigned.

Starter Code

class Weather:
    def __init__(self):
        self.__temp = 0
    
    # Add @property and @temperature.setter with validation

if __name__ == '__main__':
    t = int(input())
    w = Weather()
    # Set property 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