11  Working with Repetition Structures

11.1 Task : Creating a selective reversed list

11.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 repetition with the following within:
    • A function named myrepetition.
      • 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 Lists with the brand names in only the even/(pares) poslitions in reverse order.

11.2 Task : Managing a selective List

11.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 repetition with the following within:
    • A function named myrepetition2.
      • This function will receive as parameters 1 list and 1 tupple: one with comercial car brands and another with those brands cars horsepower.
        • Ex: commercial = [“Bmw”,“Audi”,“Volvo”,“Mercedes”,“Ferrari”] , hpower = (520,622,640, 675, 618).
        • The function should return 1 dictionary with the brand names in only the even/(pares) positions and if the car horsepower is bigger that 600. The dictionary should contain as values the word “Big Car” if the horsepower is bigger that 650, “Medium Car” if the horsepower is between 620 and 650 and “Small Car” if its below 620.

11.3 Task : Managing exceptions

11.3.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 repetition with the following within:
    • A function named myrepetition3.
      • This function will receive as parameters 3 lists: one with comercial car brands and another with those brands cars horsepower, and the last one with the number of cylinders.
        • Ex: commercial = [“Bmw”,“Audi”,“Volvo”,“Mercedes”,“Ferrari”] , hpower = [520,622,640, 675, 618], cyl=[10,40,0,50,0].
        • The function should return 1 dictionary with the brand names if the car horsepower is bigger that 600. The dictionary should contain as values the word “Big Car” if the horsepower divided by the number of cylinders is bigger that 20, “Medium Car” if the division result is between 15 and 20 and “Small Car” if it’s below 15.