Table of Contents

    Hands-On Probability and Statistics: Advanced Techniques and Applications - Part 3

    Hands On: Probability and Statistics -3

    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 out 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


    Solution Code

    
    import math
    
    def dancers():
        '''
        output: ans : Integer
        '''
        #Write your code here
        #Assign your value to variable ans
         # Number of ways to select 3 boys out of 6
        # Number of ways to select 3 boys out of 6
        boys_ways = math.comb(6, 3)
        # Number of ways to select 2 girls out of 5
        girls_ways = math.comb(5, 2)
        # Total number of ways to select 5 dancers consisting of 3 boys and 2 girls
        total_ways = boys_ways * girls_ways
        ans = total_ways
        return int(ans) 
         
    
    if __name__=='__main__':
    	print(dancers())