Circle Class

You are asked to create a Circle class which should include the following:
  1. An __init__ method that sets the radius of the circle. If no radius is provided during instantiation, the default radius value should be 1.
  1. A method area() that calculates and returns the area of the circle.
  1. A method circumference() that calculates and returns the circumference of the circle.
The methods should not print the results but return them.
You should use the math module to calculate the area and the circumference.
Input
Output
circle = Circle(); print(circle.area()); print(circle.circumference())
3.141592653589793 6.283185307179586
circle = Circle(3); print(circle.area()); print(circle.circumference())
28.274333882308138 18.84955592153876
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue