Answered step by step
Verified Expert Solution
Question
1 Approved Answer
11. You need to write a code to find the largest key in a dictionary d and associate the corresponding value with the variable val_of_max.
11. You need to write a code to find the largest key in a dictionary d and associate the corresponding value with the variable val_of_max. For example, given the dictionary 5:3, 4:1, 12:2), 2 would be associated with val_of_max. Assume d is not empty. Fill in the blanks in the following incomplete code to achieve the right result The partial code maxKey list(d.keysO)[0] for k in d.keys() if k maxKey val of max-d(maxKey] 12. A file named numbers.txt contains an unknown number of lines, each consisting of a single integer (+ve, -ve or 0). Below is an incomplete code that reads data from numbers file creates two files, dataplus.txt containing all positive integers from the numbers.txt file and dataminus.txt containing all negative integers from the numbers.txt file. Zeros are not copied anywhere. Fill in the blanks in the following code to achieve the desired result The partial code is infile- open("numbers.txt", "r") plus-open("dataplus.txt", "w"); minus-open("dataminus.txt", "W"); for line in infile if plus write(line) elif minus.write(line) infile.close() plus.close0) minus.close)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started