Answer:
Dictionary can be represented using {} using key and value pairs. separated by colons.
so correct syntax is :
a={'key':'value'}
a['key'] retrieves value.
Dictionary is represented using {} but not [],().
![a={key:value} print(a[key])](http://img.homeworklib.com/questions/0f3cf7c0-664a-11eb-9df4-915fb687a510.png?x-oss-process=image/resize,w_560)
output:

9 1 point Identify which of the following can be used as keys in a dictionary....
Implement the function flip_dict which takes in a dictionary and returns a similar dictionary where the values have become the keys and the keys have become the values. In this problem, you can assume that each key value pair is unique, and no key or value will be repeated or used more than once. def flip_dict(dictionary): """Returns a flipped version of the original dictionary. >>> TAs = {"12pm-2pm": "brian", "10am-12pm": "sophia", "2pm-4pm": "alec"} >>> flipped_TAs = flip_dict(TAs) >>> sorted_keys =...
Storing data and adding to data in a dictionary: Experiment with Python dictionaries and their keys() member function that returns a list of a dictionary's keys. You can check if a particular key is in a dictionary by using the in test with the keys list. For example, if our dictionary is MyDict = { 1: 'One', 2: 'Two', 3: 'Three' } Then ( 2 in MyDict.keys() ) evaluates to True, indicating that 2 is a valid key for MyDict....
USING PYTHON! a) Programmatically (do not just write a definition!) create a dictionary whose keys are the integers 1 through 10 and whose respective values are the keys cubed (e.g. a key of 5 has a value of 125). b) Write a function that, given a user inputted string, outputs a dictionary where each letter is a key and each value is the letter’s position in the string. Note that you must handle cases where a word could contain the...
1. Define the draw_histogram() function which is passed a Python dictionary as a parameter. The keys of the dictionary are single letters and the corresponding values are integers, e.g., {'b': 5, 'a': 6, 'c': 3}. For each key:value pair in the dictionary the function prints the key, followed by ": ", followed by a series of stars. The number of stars printed is given by the value corresponding to the key. The keys are printed in alphabetical order. Note that...
I have a dictionary in which has strings for keys and integers for values. I need to count the length of each key and place it in one of three categories, small, medium or large. Those are defined by: small: length 0-4, inclusive. medium: length 5-7, inclusive. large: length 8+, inclusive. After they are they have been sorted into their appropriate category, the program needs to check which word of each small, medium, large category had the largest key. Sample...
Python 3, nbgrader, pandas 0.23.4
Q2 Default Value Functions (1 point) a) Sort Keys Write a function called sort_keys, which will return a sorted version of the keys from an input dictionary Input(s): dictionary :dictionary reverse boolean, default: False Output(s): .sorted_keys: list Procedure(s) Get the keys from the input dictionary using the keys()method (this will return a list of keys) Use the sorted function to sort the list of keys. Pass in reverse to sorted to set whether to reverse...
Your program has a dictionary called classes. The keys in classes are teacher's last names (as strings), and the corresponding values are the number of students in that teacher's class. For example, if Mr. Brown has 17 students in her class, then 'Brown' might be a key in classes with a corresponding value of 17. Write a few lines in Python that will do the following: Ask the user to enter the last name of a teacher IF that last...
python
Which of the following statements are true? SELECT ALL THAT APPLY A dictionary is not iterable. If die is a dictionary, dictionary returns a list of all the keys in the If my_dict is a dictionary, it can be sorted in ascending order of its keys using the dictionary's sort function. If my_dict is a dictionary, and k is a variable, the structure k in my_dict returns True if k is a key in the dictionary.
HW13.13. Update a dictionary, following some rules, with another dictionary Define a function below, update_dict_with_rules, which takes two arguments: both are a dictionary of strings (keys) to integers (values). Complete the function such that it updates the first dictionary as follows: • For key-value pairs in both dictionaries, sum them • For key-value pairs in the second dictionary only, insert them into the first • Make no changes to key-value pairs unique to the first dictionary These updates should be...
HW13.13. Update a dictionary, following some rules, with another dictionary Define a function below, update_dict_with_rules, which takes two arguments: both are a dictionary of strings (keys) to integers (values). Complete the function such that it updates the first dictionary as follows: • For key-value pairs in both dictionaries, sum them • For key-value pairs in the second dictionary only, insert them into the first • Make no changes to key-value pairs unique to the first dictionary These updates should be...