Puzzle

We count 31 heads and 96 legs among the chickens and rabbits in a farm. How many rabbits and how many chickens do we have?

internet

Solution

# Inputs containes ( Chickens and Rabbits)
heads = 31 
legs = 96

def solve(h,l):
      if (l>h) and (legs%2==0):
        rabbit = (l-2*h)//2
        chick = h-rabbit
        print(f' There are {rabbit} Rabbits and {chick} chickens.')  
        
# Call the function 
solve(heads, legs) 
# Out put :  There are 17 Rabbits and 14 chickens..

Spread the love
0 CommentsClose Comments

Leave a Reply

%d bloggers like this: