Write a python program to entre input radius of circle and prints is area.
Answers
This question is about to find the area of a circle by taking user input for radius of a circle.
This is similar to what we do in mathematics.
The area of a circle is pi times the radius squared. i.e. A = πr².
Let's implement the same logic in our program.
Required program:
# Importing math module
import math
# Taking user input to take radius of the circle
radius = float(input("Enter the radius of a circle: "))
# Calculating the area of the circle
area_of_circle = math.pi * pow(radius,2)
# Printing the final result
print("The area of a circle with radius ", radius, "units is ", round(area_of_circle,2), "square units.")
Program explanation:
First we imported the math module for the value of pi.
We ask the user to input the value of radius of the circle and stored it in float type. Since we don't know what kind of value the user will input.
We use the formula for finding the area of a circle.
Then, we assign the result using print function.
Answer:
rad = float(input("Enter the radius of the circle:"))
area = 3.14*rad*rad;
print("The area of circle with radius",rad,"is",area)
Explanation: