This is my first Python project, so:
create a pot with dimensions (radius, thickness of wall, thickness of base, height), fill it with food (to a specific height). Determine the ratio between the volume of the food and the volume of the (metal in the) pot.
I am aware that this code does not take handles, rims, dents and other funny stuff into consideration.
import math
pi = math.pi
class Pot:
"""create a pot with contents, determine the ratio between the contents and the pot"""
def __init__(self,inner_radius,wall_width,base_thickness,height,content_height):
self.wall_width = wall_width
self.inner_radius = inner_radius
self.outer_radius = self.inner_radius + self.wall_width
self.base_thickness = base_thickness
self.height = height
self.content_height = content_height
def get_cylinder_volume(self,radius,height):
cylinder_volume = pi * (radius ** 2) * height
return cylinder_volume
def get_pot_wall(self):
inner_cylinder = self.get_cylinder_volume(self.inner_radius,self.height)
outer_cylinder = self.get_cylinder_volume(self.outer_radius,self.height)
pot_wall = outer_cylinder - inner_cylinder
return pot_wall
def get_pot_base(self):
pot_base = self.get_cylinder_volume(self.inner_radius,self.base_thickness)
return pot_base
def get_pot_volume(self):
pot_volume = self.get_pot_base() + self.get_pot_wall()
return pot_volume
def get_content(self):
content = self.get_cylinder_volume(self.inner_radius,self.content_height)
return content
def get_ratio(self):
ratio = self.get_content()/self.get_pot_volume()
return ratio
def check_ratio(self,desired):
if (self.get_ratio() < desired):
print ("too small")
else:
print (self.get_ratio())