Example
Input
enter the radius of the circle 5
Output
The diameter of the circle is : 10
The circumference of the circle is: 31.4
Required to Know
Use of Variables, Use of different operators like assignment or arithmetic operators, Use of functions like print(), and input(), and Use of Data types..
Formula
diameter of the circle = radius of the circle * 2
circumference of the circle = 2 * 3.14 * radius of the circle
Steps
Take the radius as input from the circle.
Use the formula to find the Diameter and circumference of the circle.
Print the value of the Diameter and circumference of the circle.
Program
# Get the radius of the circle from the user
radius = float(input("Enter the radius of the circle: "))
# Calculate the diameter of the circle
diameter = 2 * radius
# Calculate the circumference of the circle
circumference = 2 * 3.14 * radius
# Print the diameter and circumference of the circle
print("The diameter of the circle is: ", diameter)
print("The circumference of the circle is: ", circumference)