Python Program to find area of circle

Program

import math;
radius = int(input("Enter the radius of circle:\t"))
area = math.pi * radius * radius
print("The area of circle is:\t{0}".format(area))

This program calculates the area of a circle using the formula:
[
\text{Area} = \pi \times \text{radius}^2 ]
where ( \pi ) (Pi) is approximately 3.14159.

import math;
  • Imports the math module, which provides mathematical functions including the constant math.pi (which represents the value of π).
radius = int(input("Enter the radius of circle:\t"))
  • The user is prompted to enter the radius of the circle.
  • input() function reads the input as a string.
  • int() converts the input string into an integer.
area = math.pi * radius * radius
  • The formula for the area of a circle is used:
    [
    \text{Area} = \pi \times \text{radius}^2 ]
  • math.pi provides the value of π (3.141592653589793).
  • The calculated area is stored in the variable area.
print("The area of circle is:\t{0}".format(area))
  • The print() function displays the computed area using string formatting.

Key Takeaways:

  1. Uses math.pi to get an accurate value of π.
  2. Uses the formula ( \pi \times \text{radius}^2 ) to compute the area.
  3. Uses input() to take user input and format() for formatted output.

Output

Enter the radius of circle:	6
The area of circle is:	113.097335529