Count Number of animals in a zoo from given number of head and legs | Function that calculates Rabbits ; Driver code
def countRabbits ( Heads , Legs ) : NEW_LINE INDENT count = 0 NEW_LINE count = ( Legs ) - 2 * ( Heads ) NEW_LINE count = count / 2 NEW_LINE return count NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT Heads = 100 NEW_LINE Legs = 300 NEW_LINE Rabbits = countRabbits ( Heads , Legs ) NEW_LINE print ( " Rabbits ▁ = " , Rabbits ) NEW_LINE print ( " Pigeons ▁ = " , Heads - Rabbits ) NEW_LINE DEDENT