Task : Creating a Tuple
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 tuples with the following within:
- A function named mytuple.
- This function will receive as parameters 2 lists: one with car brands and another with those cars maximum spped.
- Ex: cars = [“Bmw”,“Audi”,“Volvo”] , speeds = [250,230,220]
- The function should return a Tuple with the above data as follows.
- Ex: {‘Bmw’,250,‘Audi’,230,‘Volvo’,220}
Task : Evaluating Tuple Items
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 tuples with the following within:
- A function named mytuple2.
- This function will receive as parameters 2 lists: one with car brands and another with those cars maximum spped.
- Ex: cars = [“Bmw”,“Audi”,“Volvo”,“Audi”] , speeds = [250,230,220,240]
- The function should return a Tuple with the above data as follows.
- Ex: {‘Bmw’,250,‘Audi’,230,‘Volvo’,220,‘Audi’,240}
Task : Counting Tuple Items
- Within this package, create a module named tuples with the following within:
- A function named mytuplecount.
- This function will receive a tuple as parameter
- This function should return as a dictionary the number of occurrences of each element in that tuple.
- Ex: {‘Bmw’:1,250:1,‘Audi’:2,230:1,‘Volvo’:1,220:1,240:1}
- Elements can be on any order