8. Write a program to display area and circumference of circle.

# Program to find the area and circumference of circle
"""
In this program, we have to calculate the area and circumference of circle
We have the formula, 
a= pie*r^2
v=2*pie*r
As we already know the value of pie as 22/7 or 3.1415,
 we only have to ask the value of r from the user
"""
r = float(input('enter the radius of circle'));
a= 22/7*r ** 2
v=2*22/7*r
print("The area of circle is", a)
print("The circumference of circle is", v)
 
"""
If the radius is explicitly given.
Then we do not have to ask the value of r from the user
Let us suppose we have to find the volume of sphere whose radious is r."""
r = 3.2
a= 22/7*r ** 2
v=2*22/7*r
print("The area of circle is", a)
print("The circumference of circle is", v)
 
"""
We can also do this question by defining value of pie
 instead of giving value of pie as 22/7 or 3.1415.
"""
pie=22/7
r = float(input('enter the radius of sphere'));
a= pie*r ** 2
v=2*pie*r
print("The area of circle is", a)
print("The circumference of circle is", v)
 
"""
We can also do this by using constants. 
For that we must define the constants in next module or in seperate file.
Normally in practice, constants are rarely used in Python.
"""
Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

7.Write a program to display area of triangle when three sides are given.

Next Post

9. Write a program in python to ask distance in kilometer and convert into miles.

Related Posts