<jupyter_start><jupyter_text>Project 1 ![title](imgs/51.png)![title](imgs/52.png)![title](imgs/53.png)![title](imgs/54.png)<jupyter_code>import math

class Polygon:
    def __init__(self,n,R):
        if n < 3:
            raise ValueError('Polygon must have at least 3 sides')
        self._n = n
        self._R = R
    
    def __repr__(self):
        return f'Polygon({self._n},{self._R})'
    
    @property
    def count_vertices(self):
        return self._n
    
    def __eq__(self,other):
        if isinstance(other,Polygon):
            return self._n == other._n and self._R == other._R
        else:
            return NotImplemented
    
    def __gt__(self,other):
        if isinstance(other,Polygon):
            return self._n > other._n
        else:
            return NotImplemented
    
    @property
    def interior_angle(self):
        return 180*(self._n-2)/self._n
    
    @property
    def edge_len(self):
        return 2*self._R*math.sin(math.pi/self._n)
    
    @property
    def apothem(self):
        return self._R*math.cos(math.pi/self._n)
    
    @property
    def area(self):
        return self._n*self.edge_len*self.apothem/2
    
    @property
    def perimeter(self):
        return self._n*self.edge_len
class Polygons:
    def __init__(self,m,R):
        if m < 3:
            raise ValueError('m must be at least 3')
        self._m = m
        self._R = R
        self._polygons = [Polygon(i,R) for i in range(3,m+1)]
    
    def __len__(self):
        return self._m-2
    
    def __repr__(self):
        poly = ','.join([str(p) for p in self._polygons])
        return f'Polygons({poly})'
    
    def __getitem__(self,s):
        return self._polygons[s]
    
    @property
    def max_per_area(self):
        sort_polygons = sorted(self._polygons, key = lambda i: i.area/i.perimeter)
        print(sort_polygons)
        return sort_polygons[-1]

def test_polygon():
    try:
        p = Polygon(2,10)
        assert False, ('Creating a polygon with 2 sides: ')
    except ValueError:
        pass
test_polygon()
p = Polygons(6,6)
p
p[2]
p._polygons
p[::-1]
p.max_per_area
[(i, i.area/i.perimeter) for i in p]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12397447584320875, 'fraction_numerical': 0.014129443938012761, 'mean_word_length': 2.149210903873745, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 0, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '554253', 'license': 'MIT', 'n_tokens_mistral': 791, 'n_tokens_neox': 773, 'n_words': 164, 'path': 'Project #1.ipynb', 'repo_name': 'nikgun1984/Python-Programming-Part-2', 'size': '2194'}