Part of the series

Several example codes

~1 min read • Updated Sep 24, 2025

Program Overview

This Python program defines a class named Circle that receives the radius as an input and stores it in a variable named r.
This structure is useful for geometric calculations such as area and circumference.


Python Code:


# Define the Circle class
class Circle:
    def __init__(self, radius):
        self.r = radius  # Store radius in variable r

# Create an instance of the class with a specific radius
c = Circle(5)

# Display the radius
print("Circle radius:", c.r)

Sample Output:


Circle radius: 5

Explanation:

- The Circle class is defined with an __init__ constructor
- The radius is passed as an argument during object creation
- The radius is stored in self.r for future use
- The value of r is printed using print()


Written & researched by Dr. Shahin Siami