Я создал свой класс в отдельном файле MyMath.py
Вот его код
С помощью import MyMath импортирую его в файл main.py . Они лежат в одной директории.
Как мне использовать методы класса MyMath?
На данный момент при написании в main.py:
выходит ошибка AttributeError: module 'MyMath' has no attribute 'circle_len'
не видит аттрибутов
Вот его код
Python:
import math
from abc import ABC
class MyMath(ABC):
"""Абстрактный класс MyMath"""
@classmethod
def circle_len(cls, radius: int) -> float:
return 2 * math.pi * radius
@classmethod
def circle_sq(cls, radius: int) -> float:
return math.pi * radius ** 2
@classmethod
def cube_value(cls, edge: int) -> float:
return edge ** 3
@classmethod
def sphere_area(cls, radius: int) -> float:
return 4 * math.pi * radius ** 2
С помощью import MyMath импортирую его в файл main.py . Они лежат в одной директории.
Как мне использовать методы класса MyMath?
На данный момент при написании в main.py:
Python:
import MyMath
res_1 = MyMath.circle_len(radius=5)
print(res_1)
res_2 = MyMath.circle_sq(radius=6)
print(res_2)
res_3 = MyMath.cube_value(edge=6)
print(res_3)
res_4 = MyMath.sphere_area(radius=6)
print(res_4)
выходит ошибка AttributeError: module 'MyMath' has no attribute 'circle_len'
не видит аттрибутов