Python Program to Calculate Area of Circle
The area of a circle is calculated by the formula:
Area = π × radius²
In Python, we use math.pi for π. Below is the example where we calculate the area for a fixed radius and then take input from user.
वृत्त का क्षेत्रफल निकालने का सूत्र है:
Area = π × radius²
Python में π के लिए math.pi का उपयोग होता है। नीचे एक उदाहरण है जिसमें fixed radius और user input दोनों से क्षेत्रफल निकालेंगे।
Example 1: Fixed Radius
import math
radius = 7
area = math.pi * radius ** 2
print("Area of circle is:", area)
Output:
Area of circle is: 153.93804002589985
आउटपुट:
वृत्त का क्षेत्रफल है: 153.93804002589985
Example 2: User Input Radius
import math
radius = float(input("Enter the radius of the circle: "))
area = math.pi * radius ** 2
print("Area of circle is:", area)
Sample Output:
Enter the radius of the circle: 10
Area of circle is: 314.1592653589793
नमूना आउटपुट:
वृत्त की त्रिज्या डालें: 10
वृत्त का क्षेत्रफल है: 314.1592653589793
In the above program, the user inputs the radius, and the program calculates the area using the formula.
ऊपर दिए गए प्रोग्राम में user त्रिज्या दर्ज करता है, और प्रोग्राम क्षेत्रफल निकालता है।