Functions with Tuples and Dictionaries Mixed-Up Code QuestionsΒΆ

Create a function called addition_tup that takes in parameters lst and num and returns a tuple that contains tuples with the first value being a number from the lst and the second value being the number from the lst plus num. Round each value within the tuple to two decimal places. For example, addition_tup([1,2,3], 5) should return ((1, 6), (2, 7), (3, 8)) and addition_tup([-1,-2, -3, 0, 5], -5.2) should return ((-1, -6.2), (-2, -7.2), (-3, -8.2), (0, -5.2), (5, -0.2)).

Write a function called addition_tup that takes in parameters lst and num and returns a list that contains tuples with the first value being a number from the lst and the second value being the number from the lst plus num. Round each value within the tuple to two decimal places. For example, addition_tup([1,2,3], 5) should return ((1, 6), (2, 7), (3, 8)) and addition_tup([-1,-2, -3, 0, 5], -5.2) should return ((-1, -6.2), (-2, -7.2), (-3, -8.2), (0, -5.2), (5, -0.2)).

Create a function called greater_than_five that takes in dictionary as a parameter and returns a list of keys that correspond to values in the dictionary that are greater than 5. For example, greater_than_five({'a':1, 'b': 2, 'c':7}) should return ['c'].

Write a function called greater_than_five that takes in dictionary as a parameter and returns a list of keys that correspond to values in the dictionary that are greater than 5. For example, greater_than_five({'a':1, 'b': 2, 'c':7}) should return ['c'].

Create a function called dict_to_tup_of_tuples that takes in dictionary as a parameter and returns a tuple that contains tuples with the first value being the keys of the dictionary and the second being the values of the dictionary. For example, dict_to_tup_of_tuples({'a':1, 'b': 2, 'c':7}) would return (('a', 1), ('b', 2), ('c', 7)).

Write a function called dict_to_tup_of_tuples that takes in dictionary as a parameter and returns a tuple that contains tuples with the first value being the keys of the dictionary and the second being the values of the dictionary. For example, dict_to_tup_of_tuples({'a':1, 'b': 2, 'c':7}) would return (('a', 1), ('b', 2), ('c', 7)).

Create a function called swap_keys_values that takes in dictionary as a parameter and returns swapped_dictionary that swaps the keys and values of the passed in dictionary. For example, swap_keys_values({'a':1, 'b': 2, 'c':7}) would return {1: 'a', 2: 'b', 7: 'c'}.

Write a function called swap_keys_values that takes in dictionary as a parameter and returns swapped_dictionary that swaps the keys and values of the passed in dictionary. For example, swap_keys_values({'a':1, 'b': 2, 'c':7}) would return {1: 'a', 2: 'b', 7: 'c'}.

Create a function called common_value_in_tups that takes in two tuples, tup1 and tup2, as parameters and returns True if any of the values in both tuples match and False otherwise. (Note: Disregard position of values.) For example, common_value_in_tups((1,2,3),(6,4,5)) should return False.

Write a function called common_value_in_tups that takes in two tuples, tup1 and tup2, as parameters and returns True if any of the values in both tuples match and False otherwise. (Note: Disregard position of values.) For example, common_value_in_tups((1,2,3),(6,4,5)) should return False.

You have attempted of activities on this page