Page 314 - Computer Science Class 11 Without Functions
P. 314

countW, countC, countP, countS = 0, 0, 0, 0
              continueOrNot = 'y'
              clothingList = []


              while continueOrNot =='y':
                  clothingId = int(input("Enter the clothing id :  "))
                  clothingName = input("Enter name of the clothing :  ")
                  inputCategory = input("Enter category of clothing :  ")

                  if inputCategory not in clothCategory:
                      print(" Sorry...We do not deal with ", inputCategory)
                      continue

                  clothRecord = [clothingId,clothingName,inputCategory]

                  clothingList.append(clothRecord)
                  continueOrNot = input(" Do you wish to continue (y/n):  ")
              for record in clothingList:
                  if record[2] == 'wedding collection':
                      countW += 1
                  elif record[2] == 'casual wear':
                      countC += 1
                  elif record[2] == 'party wear':
                      countP += 1
                  elif record[2] == 'sports wear':
                      countS += 1
              print(clothingList)
              print("Category Wise data is :   ")
              print('Wedding Collection: ', countW)
              print('Casual Wear: ', countC)
              print('Party Wear: ', countP)
              print('Sports Wear: ',countS)
           2.  Shamitabh's teacher wants him  to store the ages of all his friends in the form of a list and then perform the following
              operations:
              ●  Display the average age of all his friends
              ●  Display the count of all his friends
              ●  Display the most frequently occurring age value in the list
              Help Shamitabh to do his assignment using the Python functionality.
         Ans:  To develop the desired program to summarize the list of age, Shamitabh needs to take the following approach:
              Approach:
              a.  Prompt the user to enter age one by one and append to an initially empty list.
              b.  If the user reponds by y or Y, continue, else stop and process data.
              c.  Use mean and mode methods of statistics module.

              import statistics


         312   Touchpad Computer Science-XI
   309   310   311   312   313   314   315   316   317   318   319