Create a Python function that calculates and returns the area of a circle when given its radius as a parameter.
def calculate_circle_area(radius):
return 3.14159 * (radius ** 2)
-
Modify the function to handle negative radii gracefully and return an error message. (Hint: use the
assert
statement) [+5 extra credit points] -
Create a Python script that prompts the user to input a radius and then displays the calculated area. (Hint: use the
input
function) [+5 extra credit points] -
Enhance the function to round the calculated area to a specified number of decimal places. (Hint: use the
round
function) [+5 extra credit points]
-
Navigate to the
src
directory and edit thesolution.py
file. -
Replace the
pass
with your solution.