9  Working with Sets

9.1 Task : Creating a Set

9.1.1 Package “istec-p4”

  • Use the package you created in the previous session.
  • Use the package locally (you don’t need to publish it to everyone)
  • Within this package, create a module named sets with the following within:
    • A function named myset.
      • This function will receive as parameters 2 lists: one with comercial car brands and another with those brands present in Formula 1 races.
        • Ex: commercial = [“Bmw”,“Audi”,“Volvo”,“Mercedes”,“Ferrari”] , fone = [“Bmw”,“McLaren”,“Mercedes”,“Ferrari”,“Williams”]
      • The function should return 2 Sets with the above data as follows.
        • Ex: commercial = {“Bmw”,“Audi”,“Volvo”,“Mercedes”,“Ferrari”}
        • Ex: fone = {“Bmw”,“McLaren”,“Mercedes”,“Ferrari”,“Williams”}

9.2 Task : Managing Set Items

9.2.1 Package “istec-p4”

  • Use the package you created in the previous session.
  • Use the package locally (you don’t need to publish it to everyone)
  • Within this package, create a module named sets with the following within:
    • A function named myset2.
      • This function will receive as parameters the 2 sets obtained in the previous task.
      • The function should return a Set with all the brands selling commercial cars plus the ones that are present in the Formula 1 race.
    • A function named myset3.
      • This function will receive as parameters the 2 sets obtained in the previous task.
      • The function should return a Set with only the brands selling commercial cars and that are also present in the Formula 1 race.
    • A function named myset4.
      • This function will receive as parameters the 2 sets obtained in the previous task.
      • The function should return a Set with the brands that are present in only one of the segments.

9.3 Task : Evaluating Multiple Sets

  • Within this package, create a module named sets with the following within:
  • Create a third set containing brands running in the Rally championship - Ex: rally = {“Audi”,“Mercedes”,“Renault”}
  • Create a a function named myset5.
    • This function will receive as parameters the 3 sets (commercial, fone and rally)
    • This function should return the brands that are in the Commercial, Formula 1 and Rally segments.