Mixed-Up Code Questions

Create a function letter_dict that takes in string as a parameter and returns a dictionary containing the amount of times letters appear in the given string. For example, letter_dict('It is') should return {'i': 2, 't': 1, 's': 1}. (Note: Pretend the string doesn’t have any punctuation besides spaces.)

Write a function letter_dict that takes in string as a parameter and returns a dictionary containing the amount of times letters appear in the given string. For example, letter_dict('It is') should return {'i': 2, 't': 1, 's': 1}. (Note: Pretend the string doesn’t have any punctuation besides spaces.)

Create a function word_dict that takes in string as a parameter and returns a dictionary containing the amount of times a word appears in the given string. For example, word_dict('HELLO heLlo there  ') should return {'hello': 2, 'there': 1}. (Note: Pretend the string doesn’t have any punctuation besides spaces.)

Write a function word_dict that takes in string as a parameter and returns a dictionary containing the amount of times a word appears in the given string. For example, word_dict('HELLO heLlo there  ') should return {'hello': 2, 'there': 1}. (Note: Pretend the string doesn’t have any punctuation besides spaces.)

Create a function a_counter that takes in string as a parameter, creates a dictionary, and returns the amount of a’s in the given string using the dictionary. For example, a_counter('Alice and Apples') should return 3.

Write a function a_counter that takes in string as a parameter, creates a dictionary, and returns the amount of a’s in the given string using the dictionary. For example, a_counter('Alice and Apples') should return 3.

Create a function called sales_tax that takes in a list_of_costs (floating point values) as a parameter and returns a dictionary with the original costs as keys and the final costs after the sales tax of 6 percent as values. The final costs should be rounded to the hundredths place. For example, sales_tax([1.25, 8, 5]) returns {1.25: 1.33, 8: 8.48, 5: 5.3}.

Write a function called sales_tax that takes in a list_of_costs (floating point values) as a parameter and returns a dictionary with the original costs as keys and the final costs after the sales tax of 6 percent as values. The final costs should be rounded to the hundredths place. For example, sales_tax([1.25, 8, 5]) returns {1.25: 1.33, 8: 8.48, 5: 5.3}.

Create a function called discount_and_tax that takes in a list_of_costs (floating point values) and a discount percentage as parameters and returns a dictionary with the original costs as keys and the final costs after applying the discount (first) and the sales tax of 6 percent (second) as values. The final costs should be rounded to the hundredths place. For example, discount_and_tax([1.25, 8, 5], 20) should return {1.25: 1.06, 8: 6.78, 5: 4.24}.

Write a function called discount_and_tax that takes in a list_of_costs (floating point values) and a discount percentage as parameters and returns a dictionary with the original costs as keys and the final costs after applying the discount (first) and the sales tax of 6 percent (second) as values. The final costs should be rounded to the hundredths place. For example, discount_and_tax([1.25, 8, 5], 20) should return {1.25: 1.06, 8: 6.78, 5: 4.24}.

Create a function called create_dictionary that takes in keys_list and values_list as parameters and returns a dictionary with the keys_list as keys and the values_list as values. Assume keys_list and values_list are the same length, and they only contain numbers and strings. For example, create_dictionary(['one', 'two', 'three'], [1, 2, 3]) should return {'one': 1, 'two': 2, 'three': 3}.

Write a function called create_dictionary that takes in keys_list and values_list as parameters and returns a dictionary with the keys_list as keys and the values_list as values. Assume keys_list and values_list are the same length, and they only contain numbers and strings. For example, create_dictionary(['one', 'two', 'three'], [1, 2, 3]) should return {'one': 1, 'two': 2, 'three': 3}.

Create a function called lowest_value_keys that takes in dictionary as a parameter and returns a list of the keys containing the lowest value of all the keys in the dictionary. Assume all values of the dictionary are integers or floats. For example, lowest_value_keys({'pizza': 11, 'fruits': 0, 'toys': 0, 'rice bags': 1.9, 'ice': 1.8}) should return ['fruits', 'toys'].

Write a function called lowest_value_keys that takes in dictionary as a parameter and returns a list of the keys containing the lowest value of all the keys in the dictionary. Assume all values of the dictionary are integers or floats. For example, lowest_value_keys({'pizza': 11, 'fruits': 0, 'toys': 0, 'rice bags': 1.9, 'ice': 1.8}) should return ['fruits', 'toys'].

Create a function called duplicated_data that takes in dictionary1 and dictionary2 as parameters and returns a dictionary with key-value pairs that are in both dictionaries. For example, duplicated_data({'Ten': 10, 'Twenty' : 20, 'Thirty' : 30}, {'Ten': 10, 'Twenty' : 20}) should return {'Ten': 10, 'Twenty': 20}.

Write a function called duplicated_data that takes in dictionary1 and dictionary2 as parameters and returns a dictionary with key-value pairs that are in both dictionaries. For example, duplicated_data({'Ten': 10, 'Twenty' : 20, 'Thirty' : 30}, {'Ten': 10, 'Twenty' : 20}) should return {'Ten': 10, 'Twenty': 20}.

Create a function called total_price that takes in quantity_dict and price_dict and returns the total cost of all items. Assume keys in both dictionaries are the same, and the values in quantity_dict are integers. For example, total_price({'fries': 7, 'hot dogs': 9, 'soda': 9}, {'fries': 1.5, 'hot dogs': 1, 'soda': 1.1}) should return 29.4.

Write a function called total_price that takes in quantity_dict and price_dict and returns the total cost of all items. Assume keys in both dictionaries are the same, and the values in quantity_dict are integers. For example, total_price({'fries': 7, 'hot dogs': 9, 'soda': 9}, {'fries': 1.5, 'hot dogs': 1, 'soda': 1.1}) should return 29.4.

Create a function called scale_recipe that takes in quantity_dict and scale_factor as parameters and returns a dictionary with quantity_dict scaled by the scale_factor. For example, scale_recipe({'fries': 7, 'hot dogs': 9, 'soda': 8}, 4) should return {'fries': 28, 'hot dogs': 36, 'soda': 32}.

Create a function called scale_recipe that takes in quantity_dict and scale_factor as parameters and returns a dictionary with quantity_dict scaled by the scale_factor. For example, scale_recipe({'fries': 7, 'hot dogs': 9, 'soda': 8}, 4) should return {'fries': 28, 'hot dogs': 36, 'soda': 32}.

You have attempted of activities on this page