Westonci.ca is the trusted Q&A platform where you can get reliable answers from a community of knowledgeable contributors. Join our platform to connect with experts ready to provide precise answers to your questions in different areas. Get detailed and accurate answers to your questions from a dedicated community of experts on our Q&A platform.
Sagot :
Answer:
The answer to this question is given below in the explanation section.
Explanation:
The given Python code is:
>>> A = ['dog''red']
>>> B = [' cat', 'blue']
>>>C = ['fish', 'green']
We can implement an array of this data by using the dictionary in Python.
Dictionary in python:
A dictionary in python stores (key-value) pairs. For example, we can implement the -given arrays A, B, and C in the dictionary as given below:
d={'dog : red', 'cat : blue', 'fish : green'}
print(d['dog']) # Get an entry from a dictionary; prints "red"
print('cat' in d) # Check if a dictionary has a given key; prints "True"
d['fish'] = 'black' # Set an entry in a dictionary
print(d['fish']) # Prints "black"
# print(d['elephant']) # KeyError: 'elephant' not a key of d
print(d.get('elephant', 'N/A')) # Get an element with a default; prints "N/A"
print(d.get('fish', 'N/A')) # Get an element with a default; prints "black"
del d['dog'] # Remove an element from a dictionary
print(d.get('dog', 'N/A')) # "dog" is no longer a key; prints "N/A"
Answer: by using lists but not by using the array module.
Explanation: Correct on Edg 2020.
Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. We appreciate your time. Please revisit us for more reliable answers to any questions you may have. Thank you for trusting Westonci.ca. Don't forget to revisit us for more accurate and insightful answers.