Class Variables: Shared state basics

Easy State Management (Variables)
Solve in Playground →

Problem Statement

Create a `Circle` class with a class variable `pi = 3.14`. The `__init__` method takes `radius`. Add a method `area()` that returns `pi * radius * radius` (use the class variable `Circle.pi`).

Input Format

A single float for the radius.

Output Format

Print the calculated area.

Constraints

radius >= 0

Sample Input

2.0

Sample Output

12.56

Explanation

Class variables are shared among all instances of a class. Accessing them via the class name (`Circle.pi`) is a safe standard practice.

Starter Code

class Circle:
    # Define class variable 'pi' here
    
    # Define __init__ and area() here
    pass

if __name__ == '__main__':
    r = float(input())
    # Instantiate and print area
    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