7.9 LAB: Sorting TV Shows (dictionaries and lists) Write a program that first reads in the name of an input file and then reads the input file using the file.readlines() method. The input file contains an unsorted list of number of seasons followed by the corresponding TV show. Your program should put the contents of the inpu file into a dictionary where the number of seasons are the keys, and a list of TV shows are the values (since multiple shows could have the same number of seasons). Sort the dictionary by key (least to greatest) and output the results to a file named output_keys.txt, separating multiple TV shows associated with the same key with a semicolon (;). Next, sort the dictionary by values (alphabetical order), and output the results to a file named output_titles.txt.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter3: Input/output
Section: Chapter Questions
Problem 12SA: 12. What is the output of the following program? (2, 3, 6, 8) #include <iostream> #include...
icon
Related questions
Question
100%
Help with code please
Hups:7/learm.zybooks.com/zybook/IT-140-X4806-OL-TRAD-UG.22EW4/chapter/7/section/9
To
library > IT 140: Introduction to Scripting home > 7.9: LAB: Sorting TV Shows (dictionaries and lists)
zyBooks catalog
Help/FAQ
Gunsmoke
30
The Simpsons
10
Will & Grace
14
Dallas
20
Law & Order
12
Murder, She Wrote
the file outputkeys.txt should contain:
10: Will & Grace
12: Murder, She Wrote
14: Dallas
20: Gunsmoke; Law & Order
30: The Simpsons
and the file output_titles.txt should contain:
Dallas
Gunsmoke
Law & Order
Murder, She Wrote
The Simpsons
Will & Grace
Note: There is a newline at the end of each output file, and file1.txt is available to download.
387998 2550922.qx3zay7
rch
42 F Cloudy
Transcribed Image Text:Hups:7/learm.zybooks.com/zybook/IT-140-X4806-OL-TRAD-UG.22EW4/chapter/7/section/9 To library > IT 140: Introduction to Scripting home > 7.9: LAB: Sorting TV Shows (dictionaries and lists) zyBooks catalog Help/FAQ Gunsmoke 30 The Simpsons 10 Will & Grace 14 Dallas 20 Law & Order 12 Murder, She Wrote the file outputkeys.txt should contain: 10: Will & Grace 12: Murder, She Wrote 14: Dallas 20: Gunsmoke; Law & Order 30: The Simpsons and the file output_titles.txt should contain: Dallas Gunsmoke Law & Order Murder, She Wrote The Simpsons Will & Grace Note: There is a newline at the end of each output file, and file1.txt is available to download. 387998 2550922.qx3zay7 rch 42 F Cloudy
7.9 LAB: Sorting TV Shows (dictionaries and lists)
Write a program that first reads in the name of an input file and then reads the input file using the file.readlines() method. The input file
contains an unsorted list of number of seasons followed by the corresponding TV show. Your program should put the contents of the input
file into a dictionary where the number of seasons are the keys, and a list of TV shows are the values (since multiple shows could have the
same number of seasons).
Sort the dictionary by key (least to greatest) and output the results to a file named output_keys.txt, separating multiple TV shows
associated with the same key with a semicolon (;). Next, sort the dictionary by values (alphabetical order), and output the results to a file
named output_titles.txt.
Ex: If the input is:
filel.txt
and the contents of file1.txt are.
20
Gunsmoke
30
The Simpsons
10
Will & Grace
14
Dallas
20
Law & Order
PC
42°F Cloudy
DELL
Transcribed Image Text:7.9 LAB: Sorting TV Shows (dictionaries and lists) Write a program that first reads in the name of an input file and then reads the input file using the file.readlines() method. The input file contains an unsorted list of number of seasons followed by the corresponding TV show. Your program should put the contents of the input file into a dictionary where the number of seasons are the keys, and a list of TV shows are the values (since multiple shows could have the same number of seasons). Sort the dictionary by key (least to greatest) and output the results to a file named output_keys.txt, separating multiple TV shows associated with the same key with a semicolon (;). Next, sort the dictionary by values (alphabetical order), and output the results to a file named output_titles.txt. Ex: If the input is: filel.txt and the contents of file1.txt are. 20 Gunsmoke 30 The Simpsons 10 Will & Grace 14 Dallas 20 Law & Order PC 42°F Cloudy DELL
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 5 images

Blurred answer
Knowledge Booster
Parallel Processing
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning