Page 362 - Computer Science Class 11 With Functions
P. 362

Approach:
              a.  First create a tuple of categories:

                clothCategory = ('wedding', 'casual', 'party', 'sports')
              b.  Intialise count of each type of clothing to 0:

                countW,countC, countP, countS  = 0, 0, 0, 0
              c.  For each input (type of clothing):
                i.  If in the clothCategory, increment the appropriate count
                ii.  Otherwise print an error message

         Ans.  '''
              Objective: To count clothing for each category
              Input: clothing ids, clothing names, and clothing categories
              Output: category-wise count
              '''
              clothCategory = ('wedding collection', 'casual wear', 'party wear', 'sports wear')
              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)

         360   Touchpad Computer Science-XI
   357   358   359   360   361   362   363   364   365   366   367