Counting Active Instances of a Class

Medium State Management (Variables)
Solve in Playground →

Problem Statement

Create a `User` class with a class variable `count = 0`. Inside `__init__`, increment this class variable. Read an integer N, create N instances in a loop, and print ‘Total Users: [count]’.

Input Format

A single integer N.

Output Format

Print the total count.

Constraints

0 <= N <= 100

Sample Input

5

Sample Output

Total Users: 5

Explanation

Because class variables are shared, they act as an excellent tracking mechanism for state across all instances.

Starter Code

class User:
    count = 0
    # Define __init__ to increment count
    pass

if __name__ == '__main__':
    n = int(input())
    # Create instances in a loop and print count
    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