Quotes help make search much faster. Example: "Practice Makes Perfect"

Sunday, December 9, 2012

LearnStreet Python Lesson 9 Exercise 7


#sample solution


class Bottle:
    def __init__(self, liquid):
        self.amount= 500
        self.height = 10
        self.empty = False
        self.full = True
        self.liquid = liquid

    def amount_left(self):
        return self.amount

    def drink(self, amount):
        if amount < self.amount:
            self.amount -= amount
        elif amount == self.amount:
            self.empty = True
        else:
            print "Cannot drink more " + self.liquid + " than available"
    #your method here
    def refill(self, amount):
        if(self.amount+amount>500):
            print "You can't do that"
        else:
            self.amount+=amount

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts