Question: CSCI 1 1 3 3 , Make - up Exercise 1 2 - 2 Due: 6 : 0 0 pm , Friday November 2 2

CSCI 1133, Make-up Exercise 12-2
Due:6:00 pm, Friday November 22,2024
Late Policy: No submissions will be accepted after the deadline.
This is a make-up exercise that can be used to replace your score on In-class Exercise 12-2 if you missed the synchronous lecture, or got the incorrect answer. You are welcome to submit it for extra practice even if you dont need the points. The grading is entirely automated, and you can resubmit as many times as you want up until the deadline.
Unlike the homework and quizzes, there are no restrictions on collaboration for make-up exercises - you can freely work as a team with other students and show each other your answers. You can also ask the TAs for help via office hours or the email alias.
Exercise 12-2
Write a class Cylinder that contains information about a cylindrical object.
The Cylinder class must have two instance variables:
self.r is a floating point value describing the radius of the cylinder
self.h is a floating point value describing the height of the cylinder
The Cylinder class should also have a constructor and two methods:
__init__(self, diameter, height) takes in two parameters other than self, representing the diameter of the cylinder, and the height, and uses this information to set up self.r and self.h. Note that to get the radius (self.r) from the diameter, youll need to divide by 2.
get_surface_area(self) returns the surface area of the cylinder, given by the formula:
A =2r2+2rh
You should import math and use math.pi to get an accurate value for
get_volume(self) returns the volume of the cylinder, given by the formula:
V = r2h
Submit your code to gradescope in a file called ex12-2.py.
Examples:
if __name__=='__main__':
c1= Cylinder(10.0,20.0)
print(c1.r) #5.0
print(c1.h) #20.0
print(c1.get_surface_area()) #785.3981633974483
print(c1.get_volume()) #1570.7963267948967

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!