File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ import math
2+ import logging
3+
4+ # Configure logging
5+ logging .basicConfig (level = logging .INFO )
6+ logger = logging .getLogger (_name_ )
7+
8+ def calculate_area_of_circle (radius ):
9+ """
10+ Calculate the area of a circle given its radius.
11+
12+ Args:
13+ radius (float): Radius of the circle.
14+
15+ Returns:
16+ float: Area of the circle.
17+ """
18+ if radius < 0 :
19+ raise ValueError ("Radius cannot be negative" )
20+ return math .pi * radius ** 2
21+
22+ def main ():
23+ """
24+ Main function to demonstrate a simple calculation.
25+ """
26+ try :
27+ radius = 5.0
28+ area = calculate_area_of_circle (radius )
29+ logger .info (f"Area of circle with radius { radius } : { area :.2f} " )
30+ except ValueError as e :
31+ logger .error (f"An error occurred: { e } " )
32+
33+ if _name_ == "_main_" :
34+ main ()
You can’t perform that action at this time.
0 commit comments