Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """A small exercise in zookeeping."""
- import math
- from functools import reduce
- class Animal:
- """Animal."""
- def __init__(self, species: str, scientific_name: str, age_up_to: int, weight_range: tuple, height_range: tuple,
- diet: str, habitat: str):
- """Initialize the Animal object."""
- self.species = species
- self.scientific_name = scientific_name
- self.age_up_to = age_up_to
- self.weight_range = weight_range
- self.height_range = height_range
- self.diet = diet
- self.habitat = habitat
- def __repr__(self):
- """Animal object representation."""
- return self.species
- def find_smallest_animal_by_weight(animal_list: list) -> Animal:
- """
- Find the smallest animal by weight.
- As we want to know the smallest possible option, take the starting value of the weight range as a basis.
- If multiple animals are of the same weight, return the first one in the list.
- :param animal_list: input list of animals
- :return: Animal object
- """
- return animal_list.min(self.weight_range).First
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement