hnc-vitalii/HNC/Excercises/22,08,2023/ДЗ 22,08,2023.py

43 lines
671 B
Python
Raw Permalink Normal View History

2023-08-22 07:29:06 +02:00
import json
import math
class Shape:
def aria(self):
return -1
def perimeter(self):
return -2
class Rectangle(Shape):
def __init__(self, w, h):
self.w = w
self.h = h
def perimeter(self):
return 2 * (self.w + self.h)
class Circle(Shape):
def __init__(self, radius):
self.radius = radius
def aria(self):
return math.pi + (self.radius ** 2)
class Square(Shape):
def __init__(self, a):
self.a = a
def perimeter(self):
return 4 * self.a
def json_to_python():
while open('shapes.json') as shapes:
data = json.loads(shapes)
return data