<jupyter_start><jupyter_text>https://py.checkio.org/blog/design-patterns-part-1/https://py.checkio.org/mission/geometry-figures/solve/  My Solution<jupyter_code>import math
from decimal import Decimal

class Parameters:
    def __init__(self, length):
        self.length = length
        
    def choose_figure(self, figure):
        self.figure = figure
    
    def perimeter(self):
        return self.figure.perimeter(self.length)
        
    def area(self):
        return self.figure.area(self.length)
        
    def volume(self):
        return self.figure.volume(self.length)

class Circle:
    
    def perimeter(self, length):
        return round(2 * math.pi * length, 2)
        
    def area(self, length):
        return round(math.pi * length * length, 2)
        
    def volume(self, length):
        return 0

class Triangle:
    def perimeter(self, length):
        return round(float(3 * Decimal(str(length))),2)
        
    def area(self, length):
        return round((math.sqrt(3) * length * length)/4, 2)
        
    def volume(self, length):
        return 0

class Square:
    def perimeter(self, length):
        return round(float(4 * Decimal(str(length))),2)
        
    def area(self, length):
        return round(length * length,2)
        
    def volume(self, length):
        return 0

class Pentagon:
    def perimeter(self, length):
        return round(float(5 * Decimal(str(length))),2)
        
    def area(self, length):
        return round((math.sqrt(((2 * math.sqrt(5)) + 5)*5) * length * length)/4, 2)
        
    def volume(self, length):
        return 0

class Hexagon:
    def perimeter(self, length):
        return round(float(6 * Decimal(str(length))),2)
        
    def area(self, length):
        return round((math.sqrt(3) * 3 * length * length)/2, 2)
        
    def volume(self, length):
        return 0

class Cube:
    def perimeter(self, length):
        return round(float(12 * Decimal(str(length))),2)
        
    def area(self, length):
        return round(6 * length * length, 2)
        
    def volume(self, length):
        return round(length*length*length,2)


if __name__ == '__main__':
    #These "asserts" using only for self-checking and not necessary for auto-testing

    figure = Parameters(10)
    
    figure.choose_figure(Circle())
    print(figure.area())
    assert figure.area() == 314.16

    figure.choose_figure(Triangle())
    assert figure.perimeter() == 30

    figure.choose_figure(Square())
    assert figure.area() == 100

    figure.choose_figure(Pentagon())
    assert figure.perimeter() == 50

    figure.choose_figure(Hexagon())
    assert figure.perimeter() == 60

    figure.choose_figure(Cube())
    assert figure.volume() == 1000
    
    figure = Parameters(10)
    figure.choose_figure(Cube())
    print(figure.perimeter())
    assert figure.perimeter() == 120

    print("Coding complete? Let's try tests!")<jupyter_output>314.16
120.0
Coding complete? Let's try tests!<jupyter_text>Other Clear Solutions<jupyter_code>class Parameters:
    def __init__(self, r):
        self.r = r
        self.context = None

    def choose_figure(self, obj):
        self.context = obj

    def perimeter(self):
        return round(self.context.a[0] * self.r, 2)

    def area(self):
        return round(self.context.a[1] * self.r ** 2, 2)

    def volume(self):
        return round(self.context.a[2] * self.r ** 3, 2)


class Circle:
    a = (2 * 3.1416, 3.1416, 0)


class Triangle:
    a = (3, 0.43301, 0)


class Square:
    a = (4, 1, 0)


class Pentagon:
    a = (5, 1.7205, 0)


class Hexagon:
    a = (6, 2.5981, 0)


class Cube:
    a = (12, 6, 1)
    
if __name__ == '__main__':
    #These "asserts" using only for self-checking and not necessary for auto-testing

    figure = Parameters(10)
    
    figure.choose_figure(Circle())
    assert figure.area() == 314.16

    figure.choose_figure(Triangle())
    assert figure.perimeter() == 30

    figure.choose_figure(Square())
    assert figure.area() == 100

    figure.choose_figure(Pentagon())
    assert figure.perimeter() == 50

    figure.choose_figure(Hexagon())
    assert figure.perimeter() == 60

    figure.choose_figure(Cube())
    assert figure.volume() == 1000
    assert figure.perimeter() == 120

    print("Coding complete? Let's try tests!")
from math import pi


def rounded(f): return lambda x: round(f(x), 2)

class Parameters:

    def __init__(self, par):
        self.par = par

    def choose_figure(self, figure):
        self.figure = figure

    @rounded
    def area(self):
        return self.figure.area(self.par)

    @rounded
    def perimeter(self):
        return self.figure.perimeter(self.par)

    @rounded
    def volume(self):
        return self.figure.volume(self.par)

class RegularPoly:
    def perimeter(self, par):
        return self.nsides * par

    def area(self, par):
        return par ** 2 * self.phi

    volume = lambda *_: 0


class Circle(RegularPoly): nsides, phi = pi * 2, pi

class Triangle(RegularPoly): nsides, phi = 3, 0.43301

class Square(RegularPoly): nsides, phi = 4, 1

class Pentagon(RegularPoly): nsides, phi = 5, 1.72048

class Hexagon(RegularPoly): nsides, phi = 6, 2.598076211

class Cube(RegularPoly): nsides, phi, volume = 12, 6, 3..__rpow__
    
if __name__ == '__main__':
    #These "asserts" using only for self-checking and not necessary for auto-testing

    figure = Parameters(10)
    
    figure.choose_figure(Circle())
    assert figure.area() == 314.16

    figure.choose_figure(Triangle())
    assert figure.perimeter() == 30

    figure.choose_figure(Square())
    assert figure.area() == 100

    figure.choose_figure(Pentagon())
    assert figure.perimeter() == 50

    figure.choose_figure(Hexagon())
    assert figure.perimeter() == 60

    figure.choose_figure(Cube())
    assert figure.volume() == 1000
    assert figure.perimeter() == 120

    print("Coding complete? Let's try tests!")<jupyter_output>Coding complete? Let's try tests!
{'fraction_non_alphanumeric': 0.12708472314876584, 'fraction_numerical': 0.03352234823215477, 'mean_word_length': 2.724844720496894, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '568881', 'license': 'MIT', 'n_tokens_mistral': 2134, 'n_tokens_neox': 1896, 'n_words': 487, 'path': 'Other/Behavioral Design Pattern - Strategy.ipynb', 'repo_name': 'deepaksood619/Python-Competitive-Programming', 'size': '5996'}