Exercise 10
Write a python program that asks the user to enter the radius of a circle and return the area and perimeter.
Solution
1 2 3 4 5 6 7 8 9 10 |
# import the pi number from the math library from math import pi # read the value of radius r r = int(input("Enter the value of radius r: ")) # calculating the circle perimeter P = 2*pi*r # calculating the circle area S = pi*(r**2) print("The circle perimeter of radius r=",r," is P=",P) print("The area of the circle of radius r=",r," is S=",S) |
Younes Derfoufi
CRMEF OUJDA
1 thought on “Solution Exercise 10: perimeter and area of a circle in Python”