Question

10. Which of the following statements about python dictionary is correct? A. You can have different...

10. Which of the following statements about python dictionary is correct?

A. You can have different types of data as keys in a dictionary.
B. You can have variables as keys in a dictionary.
C. The values (key-value pairs) in a dictionary must be the types of int or float.
D. You cannot have a list as key in a dictionary.

Homework Answers

Answer #1

Statements about python dictionary:-

A. You can have different types of data as keys in a dictionary.

Answer: - Incorrect

Explanation:- Keys are unique and  keys must be of an immutable data type.

B) You can have variables as keys in a dictionary.

Answer:- Correct

Explanation:- Yes we can deal with variables as keys in a dictionary.

C.) The values (key-value pairs) in a dictionary must be the types of int or float.

Answer:- Incorrect

Explanation:- You can use other datatypes as well like string,boolean etc.

D.) You cannot have a list as key in a dictionary.

Answer:- Correct

Explanation:- list should not be used as a dictionary key.

Please hit that like or thumbs-up button it really motivates me> (Hope you will do that?)>3

Thank you!!

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In Python, I have a dictionary where the key is the stem and the value is...
In Python, I have a dictionary where the key is the stem and the value is a list of words with that stem, like this: d= {‘achiev’: [‘achieved’, ‘achieve’] ‘accident’: [‘accidentally’, ‘accidental’] … } #over 1000 items in the dictionary. How can I do for the 25 dictionary entries with the longest lists, print the stem and its list. Thank you!
Python Write the contents of the function below. It should build a dictionary with keys and...
Python Write the contents of the function below. It should build a dictionary with keys and values. For each such entry, it must enter two rows from the keyboard. The first line should constitute the key to be stored in a form with only capital letters. The user enters the value on the next row. This should be stored as an integer. If you enter a blank line as the key, the lock should end and the dictionary is returned....
Write a Python class, Flower, that has 3 instance variables name, num_petals and price which have...
Write a Python class, Flower, that has 3 instance variables name, num_petals and price which have types str, int and float. Your class must have a constructor method to initialize the variables to an appropriate value, and methods for setting the value of each instance variable (set methods) and for retrieving the instance variable values (get methods). You can use the credit card code we looked at for assistance.
3.2 Class Dictionary This class implements a dictionary using a hash table in which collisions are...
3.2 Class Dictionary This class implements a dictionary using a hash table in which collisions are resolved using separate chaining. The hash table will store objects of the class Data. You will decide on the size of the table, keeping in mind that the size of the table must be a prime number. A table of size between 5000-10000, should work well. You must design your hash function so that it produces few collisions. A bad hash function that induces...
1.Define a function value_to_key(d,value) that takes in a dictionary and a value as a parameter. The...
1.Define a function value_to_key(d,value) that takes in a dictionary and a value as a parameter. The function will return a list of all the keys that correspond with that value. If the value does not appear in the dictionary, it will return an empty list. ex.value_to_key({‘a’: 1, ‘b’: 4, ‘c’: 7}, 4) returns [‘b’] 2.Define a function input_tracker(number)that prompts the user to input values into the console a number of times.The function will return a dictionary where the keys are...
(Python 3) If I have a list of keys and 3 lists of values, how can...
(Python 3) If I have a list of keys and 3 lists of values, how can I append these values into an existing key, value pair in a dictionary? Say I have: mykeys = ["John", "Sarah", "Lexi, "Cass"] values1 = [3, 5, 2, 6] values2 = [17, 18, 12, 21] values3 = [4, 7, 3, 0] How can I make it so my dictionary contains all three values in each of the keys. i.e.: {"John" : [3, 17, 4], "Sarah":...
The following program implements a key-value data structure in which values are stored based on a...
The following program implements a key-value data structure in which values are stored based on a string keyword. Currently, the program allows new keys and values to be entered, but there is no function to retrieve the values given a search key. Complete the get_value function to retrieve a value given a search key. The function should print "INVALID KEY" if the key is not present. Do not remove any code OR add any code to main. You should only...
using python 2.: "Which of the following statements is ``WRONG`` about Object? <br>\n", "(A) An object...
using python 2.: "Which of the following statements is ``WRONG`` about Object? <br>\n", "(A) An object has an id, which can be obtained by using the function ``id`` <br>\n", "(B) An object has a type, which can be obtained by using the function ``type``<br>\n", "(C) int numbers (type: int, e.g., 10) in Python are not objects <br>\n", "(D) The id of an object is unique during the lifetime of the object"
12) Using the code in question 8: Write the python statement which will remove both the...
12) Using the code in question 8: Write the python statement which will remove both the key ‘gpa’ and its value 2.8 from s2 13) True or False? A dictionary is a set of items; each item consists of a colon-separated key and value. Each item is separated from other items using a comma. Dictionaries may contain both simple and complex data types. A dictionary may contain data about a single object. Another dictionary may contain data about multiple objects....
Answer question for C# 1 of 10 When items are added or removed, a list resizes...
Answer question for C# 1 of 10 When items are added or removed, a list resizes itself. True False Question 2 of 10 What happens when you assign one list to another using the assignment operator? An error message generates. Elements copy to new memory locations. Both lists become value-type data elements. Both lists reference the same memory locations. Question 3 of 10 Which of the following is a valid example of calling a method and sending it an array...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT