Create a PYTHON program that takes the radius and height from the user and finds the area of the cylinder USING CLASSES.
1. Create a class named Cylinder
2. Create an object for the class.
3. Make sure radius and height are object members
4. Using the object, call the method area() with the parameters as the radius and height taken from the user.
5. Print the area.
6. Exit
Answers
Answered by
3
Required object oriented program is in the attachment, can't type the códe here because of prohibited word.
Output of the program will be :-
>>> The area of cylinder is 345.57519189487726
Explanation :-
- Firstly import math module inorder to substitute exact value of pi ( π ).
- Now create a class named "Cylinder" as mentioned in the question by using "class" keyword.
- Create a function inside this class to find the area of cylinder.
- Formula to calculate total surface area of cylinder is 2πr (r + h) where r = radius and h = height.
- Now create the object of the class by syntax :- object_name = class_name(). function_name(argument)
Attachments:
Similar questions