Computer Science, asked by swati100294, 9 months ago

We have a count 35 heads and 94 legs among the chickens and rabbits in a farm. How many rabbits and how many chickens do we have? Write a program to get the answer,

Answers

Answered by smithakamat18
0

Explanation:

thankyou it may help u .........okok

Attachments:
Answered by da4729204
1

Answer:

23 chicken 12 rabbits

Code(python) :

#---------------------------------------------------------

# Code to be written is in bold and big letters if you dont need explanation just watch bold lines

# this is a comment

# i am using python

#---------------------------------------------------------

heads = 35

legs = 94

#---------------------------------------------------------

# let x be chickens and y be rabbits

# total animals = total heads = x + y = 35(heads) eq 1

#---------------------------------------------------------

total_animals = heads

#---------------------------------------------------------

# chicken have 2 legs and rabbit have 4 legs

# total legs = 2*x + 4*y = 94(legs) ** eq 2

# we need to solve this 2 linear equations to get answer

# dividing eq 2 by 2 we get, x + 2y = legs/2 ** eq 3

# dividing eq 1 by 2 we get, 2x + 2y = heads*2 ** eq 4

# then we will find x and y now see the code i have written to do the same

#---------------------------------------------------------

chickens = (heads*2) - (legs/2)

rabbits = total_animals - chickens

print("Number of chickens are : ",chickens)

print("Number of rabbits are : ",rabbits)

#---------------------------------------------------------

#Output of program is

# Number of chickens are : 23

# Number of rabbits are : 12

# if you changed number of heads and legs the program will work correctly

#---------------------------------------------------------

Attachments:
Similar questions