def make_animal(kind): if kind == 'cat': return cat.Cat() if kind == 'dog': return dog.Dog() if kind == 'sheep': return sheep.Sheep() return animal.Animal(kind)
def make_animal(kind): """Create an animal class.""" if kind == 'cat': return cat.Cat() if kind == 'dog': return dog.Dog() if kind = 'lion': return lion.Lion()
def make_animal(kind): """Create an animal class.""" if kind == 'cat': return cat.Cat() if kind == 'dog': return dog.Dog() if kind == 'sheep': return sheep.Sheep() return animal.Animal(kind)
def main(): tabby = cat.Cat('Tabby') parrot = Bird('Parrot') armadillo = Armadillo('9-banded armadillo') tabby.make_sound() parrot.make_sound() armadillo.make_sound()
def main(): """Print Animal """ catObject = cat.Cat(vegetarian='non', eats='milk', noOfLegs=4, color='white') print(catObject) cowObject = cow.Cow(vegetarian='', eats='grass', noOfLegs=4, color='brown') print(cowObject)
def make_animal(kind): """make animal""" if kind == 'cat': return cat.Cat() if kind == 'dog': return dog.Dog() if kind == 'sheep': return sheep.Sheep() if kind == 'leopard': return leopard.Leopard() return animal.Animal(kind)
def create_animal(kind): """Create an animal class.""" if kind == 'cat': return cat.Cat() if kind == 'dog': return dog.Dog() if kind == 'lion': return lion.Lion() if kind == 'leopard': return leopard.Leopard() if kind == 'sheep': return sheep.Sheep() return animal.Animal(kind)
"""Our own little animal farm.""" import sys from animals import lion from animals import cat def add_animal(farm, animal): farm.add(animal) return farm def main(animals): farm = set() for animal in animals: farm = add_animal(farm, animal) print("We've got some animals on the farm:", ', '.join(farm) + '.') if __name__ == '__main__': if len(sys.argv) == 1: print('Pass at least one animal type!') sys.exit(1) main(sys.argv[1:]) if kind == 'cat': return cat.Cat() if kind == 'lion': return lion.Lion()