Answered step by step
Verified Expert Solution
Link Copied!

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.

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

More Books

Students also viewed these Databases questions

Question

\f\f\f\f

Answered: 1 week ago