Question: Programing Language: Python Hello, Could I get help with these? I. landUse.py has a land usage dictionary landUse = {'res': 1, 'com': 2, 'ind': 3,
Programing Language: Python
Hello,
Could I get help with these?
I. landUse.py has a land usage dictionary
landUse = {'res': 1, 'com': 2, 'ind': 3, 'other' :[4,5,6,7]}.
Add code to the script to use common dictionary operations and methods to perform the following tasks:
(a) Print the value of the item with key 'com'.
(b) Check if the dictionary has key 'res' and print the result.
(c) Increment the value of the item with key 'ind' and then print the result.
(d) Use access by key format to add an item with land use of 'agr' and a value of 0. (Then print the dictionary.)
(e) Change the land use 'res' value to 10. (Then print the dictionary.)
(f) Print a list of the dictionary keys.
(g) Print the dictionary values, one per line, using a FOR -loop.
(h) Print a list of the dictionary items.
(i) Delete the item with key 'ind'. (Then print the dictionary.)
(j) Check for membership of the key 'ind', using the keyword in. Print the result.
Printed output should appear as follows: >>>
1. Print the value of the item with key 'com': 2
2. Check if the dictionary has key 'res': True
3. Increment the value of the item with key 'ind': 3
4. Add an item with land use 'agr' a value of 0: {'ind': 3, 'res': 1, 'other': [4, 5, 6, 7], 'com': 2, 'agr': 0}
5. Change land use 'res' value to 10. {'ind': 3, 'res': 10, 'other': [4, 5, 6, 7], 'com': 2, 'agr': 0}
6. Print a list of the dictionary keys: ['ind', 'res', 'other', 'com', 'agr']
7. Print the dictionary values:
3
10
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
