Python打卡:Day28

import math

 

 

class Circle:

    def __init__(self, radius=1):

        self.radius = radius

 

    def calculate_area(self):

        return math.pi * self.radius**2

 

    def calculate_circumference(self):

        return 2 * math.pi * self.radius

 

 

circle = Circle(5)

 

print(f'半径: {circle.radius}')

print(f'面积: {circle.calculate_area():.2f}')

print(f'周长: {circle.calculate_circumference():.2f}')

 

 

 

 

 

你可能感兴趣的:(python打卡,python)