Question: CSCI 1 1 3 3 , Make - up Exercise 1 2 - 2 Due: 6 : 0 0 pm , Friday November 2 2
CSCI Makeup Exercise
Due:: pm Friday November
Late Policy: No submissions will be accepted after the deadline.
This is a makeup exercise that can be used to replace your score on Inclass Exercise 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 makeup 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
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:
initself 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 selfr from the diameter, youll need to divide by
getsurfaceareaself returns the surface area of the cylinder, given by the formula:
A rrh
You should import math and use math.pi to get an accurate value for
getvolumeself returns the volume of the cylinder, given by the formula:
V rh
Submit your code to gradescope in a file called expy
Examples:
if namemain:
c Cylinder
printcr #
printch #
printcgetsurfacearea #
printcgetvolume #
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
