Traditional Getters & Setters

Medium Encapsulation & Data Hiding
Solve in Playground →

Problem Statement

Create a `Game` class with a private `__score` initialized to 0. Add `get_score()` and `set_score(val)` methods. Read an input, use the setter to update the score, and use the getter to print ‘Score: [val]’.

Input Format

A single integer.

Output Format

Print the retrieved score.

Constraints

None

Sample Input

95

Sample Output

Score: 95

Explanation

Traditional getter and setter methods explicitly control access to private data.

Starter Code

class Game:
    # Define __init__, get_score, and set_score
    pass

if __name__ == '__main__':
    val = int(input())
    # Instantiate, set score, and print using getter
    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