Exercise 10 

Write a program in Python that asks the user to enter the radius of a circle and return the area and perimeter.

Solution

# import the pi number from math library
from math import pi
# ask user to type a value of radius
r = int(input("Type a value of radius r: "))
# calculate the perimeter of the circle
perimeter = 2*pi*r
# calculate the area of the circle
area = (pi**2)*(r**2)
print("The perimeter of circle with radius r =",r," is perimeter = ", perimeter)
print("The area of circle with radius r =",r," is area = ", area)

Younes Derfoufi

Leave a Reply