Skip to content

Create a Python function that calculates and returns the area of a circle when given its radius as a parameter.

License

Notifications You must be signed in to change notification settings

teamkooestscholar/001PY-area-of-the-circle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

EASY: 001 Python - Calculate the Area of a Circle

Description

Create a Python function that calculates and returns the area of a circle when given its radius as a parameter.

Sample solution

def calculate_circle_area(radius):
    return 3.14159 * (radius ** 2)

Bonus Challenges

  • 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]

How to answer?

  • Navigate to the src directory and edit the solution.py file.

  • Replace the pass with your solution.

About

Create a Python function that calculates and returns the area of a circle when given its radius as a parameter.

Topics

Resources

License

Stars

Watchers

Forks

Languages