Computer Science, asked by gopaljigupta848487, 9 months ago

Write a program in python to take radius and height and print perimeter of circle and volume of cylinder .​

Answers

Answered by AbhijithPrakash
16
  1. ## I'll be defining 2 functions, i.e., perimeter_of_circle() and volume_of_cylinder().
  2. from math import pi  ## I imported the value of pi from the inbuilt function, called math.
  3. ## You can also assign a variable with the value of pi.
  4. def perimeter_of_circle(): ## This function is defined for giving/printing the perimeter of the circle.
  5.    perimeter = 2*pi*r  ## This is the formula to find the perimeter of a circle.
  6.    print("\nThe perimeter of the circle of the cylinder is {}.".format(round(perimeter,4))) # This will print the perimeter of the circle.
  7. def volume_of_cylinder():  ## This function is defined for giving/printing the volume of the cylinder.
  8.    volume = pi * r**2 * h  ## This is the formula to find the volume of a cylinder.
  9.    print("\nThe volume of the cylinder is {}.".format(round(volume,4))) # This will print the volume of the cylinder.
  10. # Driver Code
  11. r = float(input("Type the value of the radius : ")) # The will make the user input the value of the radius.
  12. h = float(input("Type the value of the height : ")) # The will make the user input the value of the height.
  13. ## Calling the functions.
  14. perimeter_of_circle()
  15. volume_of_cylinder()
Attachments:
Answered by Equestriadash
17

The following codes must be typed in script mode, saved and then executed.

CODE:

r = float(input("Enter the radius of the circle:"))

pm=2*3.14*r

print("The perimeter of the circle is:", pm)

h = float(input("Enter the height of the cylinder:"))

rad = float(input("Enter the radius of the cylinder:"))

vol = 2*3.14*rad*h

print("The volume of the cylinder is", vol)

OUTPUT:

Attachments:
Similar questions