7  Working with Dictionaries

7.1 Task : Creating a Dictionary

7.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 dictionaries with the following within:
    • A function named mydictionary.
      • This function will receive as parameters 2 lists: one with keys and another with values.
        • Ex: keys = [“John”,“Mary”,“Martha”] , values = [35,43,28]
      • The function should return a dictionary of the above data.
        • Ex: {‘John’:35, ‘Mary’:43, ‘Martha’:28}

7.2 Task : Changing Dictionary Items

7.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 dictionaries with the following within:
    • A function named mydictionary2.
      • This function will receive as parameters 1 dictionary and 2 lists: one list with keys and another with values.
      • Ex: {‘John’:35, ‘Mary’:43, ‘Martha’:28}
      • Ex: keys = [“Peter”,“John”] , values = [65,43]
      • The function should return a dictionary with the addition of the items above.