Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.This is a Python programming langauege. I got these codes, but I can\'t answer

ID: 3694535 • Letter: 1

Question

1.This is a Python programming langauege. I got these codes, but I can't answer questions blew the codes. The topic is Classes and object oriented programs

coverage = 350 #One gallon of paint covers 350 sq feet

def main():

    bedroom = room(10, 15, 8)

    print(bedroom.paint_needed())

    print(bedroom.paint_needed(2))

    dining_room = room(12, 11, 8)

    print(dining_room.paint_needed())

    print(dining_room.paint_needed(2))

class room(object):

    def __init__(self, l, w, h):

        self._length = l

        self._width = w

        self._height = h

    def paint_needed(self, coats = 1):

        ###Gallons of paint needed for a room. Can specify number of coats of paint needed, default is 1 ###

        area = (self._length*self._height*2) + (self._width*self._height*2)

        paint_gallons = (area / coverage) * coats

        #Chop off all but 2 decimal places.

        paint_two_significant_figure = int(paint_gallons * 100) / 100.0

        return paint_two_significant_figure

main()

Questions

And the full program – copy and paste, run and test.

Can you create an object to represent another room – perhaps the hall, which is 15 x 4 x 8?

How about another bedroom, 12 x 13 x 8?

Can you store all of these rooms in a list?

What if we wanted to store the new paint color for the room?

Explanation / Answer

coverage = 350 #One gallon of paint covers 350 sq feet
def main():
#list1 store all of the rooms in a list
list1 = []
# dict1 stores the new paint color for the room
dict1 = {}

bedroom1 = room(10, 15, 8)
print(bedroom1.paint_needed())
print(bedroom1.paint_needed(2))
list1.append("bedroom1")
input = raw_input("new Color for bedroom1: ")
dict1["bedroom1"] = input

dining_room = room(12, 11, 8)
print(dining_room.paint_needed())
print(dining_room.paint_needed(2))
list1.append("dining_room")
input = raw_input("new Color for dining_room: ")
dict1["dining_room"] = input

hall = room(15,4,8)
print(hall.paint_needed())
print(hall.paint_needed(2))
list1.append("hall")
input = raw_input("new Color for hall: ")
dict1["hall"] = input

bedroom2 = room(12, 13, 8)
print(bedroom2.paint_needed())
print(bedroom2.paint_needed(2))
list1.append("bedroom2")
input = raw_input("new Color for bedroom2: ")
dict1["bedroom2"] = input

#printing the list of rooms
print list1
# printing the color of rooms
print dict1

class room(object):
def __init__(self, l, w, h):
self._length = l
self._width = w
self._height = h
def paint_needed(self, coats = 1):
###Gallons of paint needed for a room. Can specify number of coats of paint needed, default is 1 ###
area = (self._length*self._height*2) + (self._width*self._height*2)
paint_gallons = (area / coverage) * coats
#Chop off all but 2 decimal places.
paint_two_significant_figure = int(paint_gallons * 100) / 100.0
return paint_two_significant_figure
main()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote