Drain Method

Take this Bathtub class and add a drain method to it, so that when you send it an amount in liters (float) it will subtract that amount from the tub’s current_volume.

Starter code

class Bathtub:
    def __init__(self, color: str, current_volume: float) -> None:
        self.color = color
        self.current_volume = current_volume
    
    # add 'drain' method here


tub = Bathtub("white", 19.5)
tub.drain(10)
print(tub.current_volume)  # should be 9.5

©2021 Daniel Gallo

This work is licensed under Attribution-NonCommercial-ShareAlike 4.0 International