Problem Statement
The teacher wants a group to be formed for the upcoming dance competition. She wants a group of 5 dancers consisting of 3 boys and 2 girls. In how many ways can a group of 5 dancers be formed by selecting 3 boys out of 6 and 2 girls our of 5? Help her out!
Write a function that returns the number of ways a group of 5 dancers consisting of 3 boys and 2 girls can be formed.
Hint:
- Use the function math.factorial()
Function Description
Function Name: dancers()
1. Output:
- Returns an integer denoting the number of ways can a group of 5 dancers be formed by selecting 3 boys out of 6 and 2 girls out of 5
Answer:
import math
def dancers():
'''
output: ans : Integer
'''
#Write your code here
boys = math.factorial(6)/((math.factorial(3))*math.factorial(3))
girls = math.factorial(5)/((math.factorial(2))*math.factorial(3))
#Assign your value to variable ans
ans=boys*girls
return int(ans)
if __name__=='__main__':
Click on output Image:
No comments:
Post a Comment
If you have any doubts, Please let us know.