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

Sunday, December 9, 2012

LearnStreet Python Lesson 9 Exercise 6


#sample solution


#Creating a class
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

# your code here
    def drink(self, amountDrank):
        self.amount -= amountDrank

#check
newBottle = Bottle("water")
print newBottle.amount_left()
newBottle.drink(200)
print newBottle.amount_left()

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts