Describe the new file created by the program: def main(): countries = PlaceDataI
ID: 3822104 • Letter: D
Question
Describe the new file created by the program: def main(): countries = PlaceDataIntoList ("UN.txt") countries.sort (key=bypop, revrse=True) createFile(countries) def placeDataIntoList(fileName): countries = [] infile = open (filename, 'x') for line in infile: line = line split(', ') if line[1] == "Europe": countries .append (list (line[0], eval (line[2])))) infile.close() return countries def bypop (country): return country[1] def createFile = (countries): outfile = open ("EuropeByPop.txt", 'w') for country in countries: outfile.write (country[0] + ', '+str(country[1]+" ") outfile close() main()Explanation / Answer
Answer:
Consider the file "UN.txt" have the following contents:
usa,
Europe,
canada
Then after traversing the program the out file will contain this data
EuropeByPop.txt:
canada,
usa
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.