Skip to content

Commit 9bc0aa4

Browse files
Testi5
1 parent ed94f51 commit 9bc0aa4

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

example.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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()

0 commit comments

Comments
 (0)