Question: PYTHON CODING #1 Write a function called list_tups_into_dict that takes in a list of tuples, list_of_tups as a parameter and returns a dictionary with the

PYTHON CODING

#1

Write a function called list_tups_into_dict that takes in a list of tuples, list_of_tups as a parameter and returns a dictionary with the first index of the tuples as the keys and the second index of the tuples as the values. For example, list_tups_into_dict([('red', 3), ('blue', 2)]) should return {'red': 3, 'blue':2}.

#2

Write a function ordered_nums_tup() that takes a tuple, tup, that contains various items such as strings and numbers and returns a sorted list of the numeric values (type int and float) sorted in ascending order. For example, ordered_nums_tup(("hello", 5, 1)) should return [1, 5]. Hint: you can use isinstance(var, type) to check if a variable is of the given type.

#3

Write a function count_chars that takes a string, str1, and returns a list of tuples ordered by the number of times each character appears in the string in descending order. For example, count_chars("babby") should return [('b': 3), ('a':1), ('y': 1)].

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!