Get startedGet started for free

Import package

Let's say you wanted to calculate the circumference and area of a circle. Here's what those formulas look like:

$$C = 2 \pi r$$ $$A = \pi r^2 $$

Rather than typing the number for pi, you can use the math package that contains the number

For reference, ** is the symbol for exponentiation. For example 3**4 is 3 to the power of 4 and will give 81.

This exercise is part of the course

Introduction to Python

View Course

Exercise instructions

  • Import the math package.
  • Use math.pi to calculate the circumference of the circle and store it in C.
  • Use math.pi to calculate the area of the circle and store it in A.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Import the math package
import ____

# Calculate C
C = 2 * 0.43 * ____

# Calculate A
A = ____ * 0.43 ** 2

print("Circumference: " + str(C))
print("Area: " + str(A))
Edit and Run Code