Advertisement
DiYane

Circle

Sep 25th, 2023
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. class Circle:
  2.     __py = 3.14
  3.  
  4.     def __init__(self, diameter):
  5.         self.diameter = diameter
  6.         self.radius = diameter / 2
  7.  
  8.     def calculate_circumference(self):
  9.         return Circle.__py * self.diameter
  10.  
  11.     def calculate_area(self):
  12.         return Circle.__py * self.radius * self.radius
  13.  
  14.     def calculate_area_of_sector(self, angle):
  15.         return (angle / 360) * Circle.__py * self.radius * self.radius
  16.  
  17. circle = Circle(10)
  18. angle = 5
  19.  
  20. print(f"{circle.calculate_circumference():.2f}")
  21. print(f"{circle.calculate_area():.2f}")
  22. print(f"{circle.calculate_area_of_sector(angle):.2f}")
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement