Write a Python program that calculates the area of a circle based on the radius entered by the user.

Program

from math import pi
def myfun():
    r = float(input("Input the radius of the circle : "))
    # Calculate the area of the circle using the formula: area = π * r^2
    area = pi * r ** 2
    print("The area of the circle with radius " + str(r) + " is: " + str(area))
      
if __name__=="__main__":      
    myfun()

Output:

Input the radius of the circle : 1
The area of the circle with radius 1.0 is: 3.141592653589793

Input the radius of the circle : 4
The area of the circle with radius 4.0 is: 50.26548245743669


More Questions


2 . Write a Python program that calculates the area of a circle based on the radius entered by the user.
3 . Write a Python program to display the current date and time.
4 . Write a Python program that accepts a sequence of comma-separated numbers from the user and generates a list and a tuple of those numbers.
5 . Write a Python program that accepts a filename from the user and prints the extension of the file.
6 . Write a Python program to display the first and last colors from the following list.
7 . Write a Python program that accepts an integer (n) and computes the value of n+nn+nnn.
8 . Write a Python program that prints the calendar for a given month and year.
9 . Write a Python program to calculate the number of days between two dates.
10 . Write a Python program to get the volume of a sphere with radius six.
11 . Write a Python program to calculate the sum of three given numbers. If the values are equal, return three times their sum.
12 . Write a Python program to count the number 4 in a given list.



For latest job updates join Telegram Channel: https://t.me/sateeshm

Programs