PYTHONSorting 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:file1.txtand the contents of file1.txt are:20Gunsmoke30The Simpsons10Will & Grace14Dallas20Law & Order12Murder, She Wrotethe file output_keys.txt should contain:10: Will & Grace12: Murder, She Wrote14: Dallas20: Gunsmoke; Law & Order30: The Simpsonsand the file output_titles.txt should contain:DallasGunsmokeLaw & OrderMurder, She WroteThe SimpsonsWill & Grace

Answers

Answer 1

Answer:

with open("file1.txt", "r") as file:

lines = file.readlines()

mydict = dict()

for x in range(0, len(lines) - 1, 2):

mydict[lines[x]] = lines[x-1]

dict_keys = sorted(mydict.keys)

sorted_dict ={}

for key in dict_keys:

sorted_dict[key] = mydict[key]

with open("output_keys.txt", "a+") as writn:

for key, value in sorted_dict.items():

writn.write(key: value)

writn.write("\n")

dict_values = sorted(mydict.values)

with open("output_titles", "a+") as title:

for name in dict_values:

title.write(name)

title.write("\n")

Explanation:

The python program above reads in the file context, files.txt, and creates a dictionary of the file with the number of seasons as the key and movie title as the value. The sorted dictionary is saved in the output_keys.txt file and the titles in output_titles.txt file.


Related Questions

Calculate the heat energy required to raise the temperature of 5 kg of water from 20℃ to

40℃. Specific heat capacity of water is 4200 J kg-1 k-1​

Answers

Given that,

Mass of water, m = 5 kg

The temperature increases from 20℃ to  40℃.

Specific heat capacity of water is 4200 J kg⁻¹ k⁻¹

To find,

Heat energy required to raise the temperature.

Solution,

The formula for the heat energy required to raise the temperature is given by :

[tex]Q=mc\Delta T\\\\=5\times 4200\times (40-20)\\\\=420000\ J\\\\=420\ kJ[/tex]

So, the heat energy required is 420 kJ.

What is the main advantage that a website builder offers for web development?

OA. It enables people with no coding skills to create websites.
OB. It allows developers to debug the code on your website.
OC. It allows developers to adjust the finer details more easily than an IDE does.
OD. It provides tools such as a resource manager and interpreter.

Answers

The correct answer is: OA. It enables people with no coding skills to create websites.

Answer: A

It enables people with no coding skills to create websites.

Explanation:

what is output? x=-2 y=-3 print (x*y+2)

Answers

Answer:

=8

Aaaaaaaaaansjxjdjsaaaaaaa

Explanation:

-2*-3=6+2=8

Write a function max_magnitude() with two integer input parameters that returns the largest magnitude value. Use the function in a program that takes two integer inputs, and outputs the largest magnitude value. Ex: If the inputs are: 5 7 the function returns: 7 Ex: If the inputs are: -8 -2 the function returns: -8 Note: The function does not just return the largest value, which for -8 -2 would be -2. Though not necessary, you may use the built-in absolute value function to determine the max magnitude, but you must still output the input number (Ex: Output -8, not 8). Your program must define and call the following function:

Answers

Answer:

The question is answered in python

def max_magnitude(a,b):

   if abs(a) > abs(b):

       return a

   else:

       return b

       

num1 = int(input("Num 1: "))

num2 = int(input("Num 2: "))

print(max_magnitude(num1,num2))

Explanation:

This question is answered using the concept of absolute value to get the integer with the highest magnitude

First, the function is defined with integer parameters a and b

def max_magnitude(a,b):

This checks if a has the highest magnitude

   if abs(a) > abs(b):

If true, it returns a

       return a

If otherwise, it returns b

   else:

       return b

       

The main starts here

The next two lines prompt the user for inputs

num1 = int(input("Num 1: "))

num2 = int(input("Num 2: "))

This calls the function

print(max_magnitude(num1,num2))


A browser is an example of a. :
general-purpose application
specialized
program
system application
utility program​

Answers

a browser is an example of a system application

What will be result of below if statement.
if (Grade >= 90)
puts("A");

What’s the answer?

Answers

Explanation:

pls check it ur answer hp u understand this

write instruction to recharge mobile phone ​

Answers

1) Grab Charger
2) Plug Charger into wall outlet
3) grab your phone
4) grab cord connected to charger
5) plug end of cord into the charger port of your phone
6) wait for phone to charge

*phone will give you a notification when it’s charging and when done*

These are some instructions to recharge a mobile phone:

You need to have a phone charger.Connect your phone charger to your phone.Then connect it to the electricity.Wait for the mobile phone to charge fully.Disconnect your phone from the phone charger and the electricity.

How do you give instructions?

In this exercise, you have to give instructions to charge a mobile phone.

When you have to give instructions it is helpful to explain every action using a specific order so it is easier for the other person to understand the instructions.

Check more information about mobile phones here https://brainly.com/question/9447658

What are differences between manual formatting and formatting in word
processor?​

Answers

Answer:-

Editing refers to making quick modification to a document using editing tools such as find and replace spelling and grammar checkers,copy and paste or undo redo features. Formatting refers to changing the appearance of text in a document such as text formatting or page formatting or paragraph formatting.

If you have a line that is 2.5 inches in decimal, what is that in fraction form?

2 5/16 inches

2 1/4 inches

2 3/4 inches

2 1/2 inches

If you are asked to measure 9/16th on a ruler how many lines would you have to count?

Answers

Answer: 2 1/2 inches; 9 lines

Explanation:

If one has a line that is 2.5 inches in decimal, this in fraction form will be written as:

= 2.5 inches = 2 5/10 inches.

When we reduce 5/10 to its lowest term, this will be 1/2. Therefore 2.5 inches = 2 1/2 inches.

Since each mark on a ruler is 1/16, therefore 9/16 will be (9/16 ÷ 1/16) = (9/16 × 16/1) = 9 lines

Write a program that prompts the user to input a string and outputs the string in uppercase letters. (Use a character array to store the string.)

Answers

Answer:

Explanation:

The following code is written in Java. It asks the user for a string/sentence and then grabs every character in the string, capitalizes it, and saves it in a char ArrayList. Then it concatenates the char array into a String variable called output and prints the capitalized String.

public static void capitalizeMe() {

               Scanner in = new Scanner(System.in);

               System.out.println("Enter a String:");

               String inputSentence = in.nextLine();

               ArrayList<Character> capitalString = new ArrayList<Character>();

               for (int x = 0; x < inputSentence.length(); x++) {

                       capitalString.add(Character.toUpperCase(inputSentence.charAt(x)));

               }

               String output = "";

               for (char x: capitalString) {

                       output += x;

               }

               System.out.println(output);

       }

i want to touch it but if i talked about the past , it would be i wanted to touch it or i wanted to touched it?​

Answers

Answer:

I wanted to touch it

Explanation:

since you put the setting in the past you can use present verbs because we already know it's something that already happened

________ reveals functional requirements regarding the exchange of data and services between systems.
a. Observations
b. User interface analysis
c. Document analysis
d. System interface analysis

Answers

The answer to this question is b

Explain the concept of Informed Consent?

Answers

Informed consent is a process of communication between you and your health care provider that often leads to agreement or permission for care, treatment, or services. Evey patient has the right to get information and ask questions before procedures and treatments.

Which type(s) of license(s) allow the underlying software code to be viewed?

a. Freeware
b. Free software

Answers

Answer:

The correct answer is B. Free software.

Explanation:

Free software is a term used for software that the holder can use, copy, read, modify and distribute with or without modification at will. Software that falls under this category includes software that is not protected by copyright laws or software that is licensed to be used in this way.

Motives for developing free software can be technical, economic or social. What is significant for developers is the desire to develop as producers of programs by learning from other producers. The desire to help others is also a major motive.

Which file extension indicates a text document? .ppt .tst .pdf .txt

Answers

Answer:

The answer is .txt

Explanation:

Answer:

.txt

Explanation:

odesseyware 2021

what is the full form of ARPANet, WAN,FTP,DCP,HTML,ISP and last WWW​

Answers

Advanced Research Projects Agency Network,

wide area network

File Transfer Protocol

?

Hypertext Markup Language

Internet service provider

world wide web

ARPANET — Advanced Research Projects Agency Network

WAN — Wide Area Network

FTP — File Transfer Protocol

DCP — Diploma Computer Programming

HTML — Hyper Text Markup Language

ISP — Internet Service Provider

www — World Wide Web

HOPE IT HELPS

PLEASE MARK ME BRAINLIEST ☺️

Where can a client identify the instant deposit options for their QuickBooks Payments account?

Deposits tab
Account and Settings
Invoices tab
Create Invoice screen
Banking Center

Answers

Answer:

Banking centre

.

.

..

.

.

.

.

.

.

.

Rosa is building a website for a multimedia company. She wants to add a drop-down menu functionality to the website's main page. Which
markup language or technology will allow Rosa to add this element?

OA. HTML
OB. Semantic HTML
OC. DHTML
OD. XML

Answers

The answer is: OC: DHTM
Explanation: PLATOLIVESMATTER

Answer:

The correct answer is C. DHTML.

Explanation:

I got it right on the Edmentum test.

A hacker posing as a potential customer has connected to your network and has discovered that a server running Windows Server has a configuration that a misconfiguration on a Windows Server that exposes the PowerShell prompt. The hacker executes a script to log valuable information about the server. Which vulnerabilities did the hacker exploit

Answers

Answer:

Lack of ips

Insecure configuration

Explanation:

Lack of IPS

This is fully known as intrusion prevention softwares this works by enabling the firewall and protecting the computer system from unauthorised users and potential attackers and it prevents data from being stolen by identifying potential attacks. It monitors the network continuously, thereby looking for possible malicious threats and also capturing informations about these threats.

Insecure configuration

Obviously if you have power shell enabled then you would have a secure configuration. Attackers can easily access your system in the presence of this flaw.

computer is an electronic machine that is used for data processing to produce meaningful information explain in statement​

Answers

A computer is an electronic machine that processes raw data to give information as output. An electronic device that accepts data as input, and transforms it under the influence of a set of special instructions called Programs, to produce the desired output (referred to as Information.) hope This helps!

Leo needs to consolidate data in multiple worksheets by performing a calculation across all worksheets on the same cells.
Which feature should he use to perform this task?
A) data consolidation
B) 3-D reference
C) grouped cells
D) linked cells

Answers

A do you think is the answer

Answer:

3-D reference

Explanation:

Edge 2022

What is Memory Card? Explain?​

Answers

A memory card is basically a card that holds memory. The card can be removed at anytime and put into any other device. It is mainly used for extra storage and to transport videos, pictures, etc. to other devices

Hope this helps.   : )

Please!! I need help, this is due by tonight!!!

Answers

Answer:

sorry if it is too late but I think it is d

Explanation:

In the program below, which variable has the same scope as strA?

def usernameMaker (strFirst, strLast):
return strFirst + strLast[0]

def passwordMaker (strA, numC):
if len(strA) > 4:
answer = dogName[0:3]
return answer + str(numC)
else:
return 'xk&' + str(numC)

Answers

Answer:

" numC " is the correct answer

Explanation:

The reason is that on line 3 of code it has "def passwordMaker (strA, numC):"

strA and numC are both in "( )" which is the scope and only things inside are varibles. Also its the only line that has  strA in it.

The scope of a variable is the extent at which the variable can be referenced.

The variable with the same scope as strA is variable numC

From the program, we have the following function definition

def passwordMaker (strA, numC):

Variables strA and numC are declared along with the function passwordMaker

This means that:

Variables strA and numC have the same scope

Hence, the variable with the same scope as strA is variable numC

Read more about scopes of variables at:

https://brainly.com/question/17102008

why ROM is called non volatila Memory?​

Answers

Answer:

Explanation:

ROMs that are read only memory are called non volatile because all of the data that are inside it happens to not get erased after shutting down the system or computer and starting it all over again. The opposite is this phenomenon is RAM. In RAM, they are being called volatile because all of the data that are inside it happens to get erased once shutting down of the system or computer occurs and it is being restarted.

This is telling us that ROM irrespective, stores data while it is on and also while it is off, it doesn't matter. It never forgets data, unless of course, in a situation whereby it is erased.

Volatile memory stores data as long as it is powered. ROM, which stands for read-only memory, is called non-volatile memory because of they do not lose memory when power is removed. Data stored in ROM cannot be electronically modified after the manufacture of the memory device.

HOPE IT HELPS

PLEASE MARK ME BRAINLIEST ☺️

what command in cisco IOS allows the user to see the routing table

Answers

Answer:

Show IP route command

Explanation:

What two solutions address lack of human access to clean water

Answers

Answer:

THREE strategies which local municipality is implementing in addressing the issue of lack of clean water caused by human factors include:

1) Increasing the amount of tax for those companies which are opening their wastes into water sources which can help built better water cleaning and recycle system.

2) Tree plantation is another strategy to help secure the water sources and naturally keep cleaning it.

3) Running awareness campaigns for general people to keep the water sources clean as well as use the only amount of water which they need and not waste it.

Explanation:

i hope this helps you

What is Code?
A) Rules of conduct
B) One or more commands designed to be carried out by a computer.
C) A pack between friends.
D) Edoc spelled backwords.

Answers

Answer:

In a class of statistics course, there are 50 students, of which 15 students  scored B, 25 students scored C and 10 students scored F. If a student is chosen at random from the class, what is the probability of scoring

not F?

Explanation:

Answer:

its b it's like opening multiple tabs

Write a program that can be used to calculate the federal tax. The tax is calculated as follows: For single people, the standard exemption is $4,000; for married people, the standard exemption is $7,000. A person can also put up to 6% of his or her gross income in a pension plan. The tax rates are as follows: If the taxable income is:

Between $0 and $15,000, the tax rate is 15%.
Between $15,001 and $40,000, the tax is $2,250 plus 25% of the taxable income over $15,000.
Over $40,000, the tax is $8,460 plus 35% of the taxable income over $40,000. Prompt the user to enter the following information:
Marital status
If the marital status is “married,” ask for the number of children under the age of 14
Gross salary (If the marital status is “married” and both spouses have income, enter the combined salary.)
Percentage of gross income contributed to a pension fund Your program must consist of at least the following functions:
Function getData: This function asks the user to enter the relevant data.
Function taxAmount: This function computes and returns the tax owed.

To calculate the taxable income, subtract the sum of the standard exemption, the amount contributed to a pension plan, and the personal exemption, which is $1,500 per person. (Note that if a married couple has two children under the age of 14, then the personal exemption is $1,500 ∗ 4 = $6,000.)

Since your program handles currency, make sure to use a data type that can store decimals with a decimal precision of 2.

Answers

Answer:

?

Explanation:

You can ask for helps on sites meant specifically for coding like cpphelp and stackoverflow

A(n) ___________________ is a set of characters that the originator of the data uses to encrypt the text and the recipient of the data uses to decrypt the text. (230)Group of answer choices

Answers

Answer:

The appropriate response will be "Public key".

Explanation:

A public key would be created in something like such key encryption cryptography consisting incorporates asymmetric encryption of the keys algorithms. Those same keys have been utilized to transform a document to even such an unintelligible form. Decryption consists done using only a separate, however corresponding, secret address or private key.

As per the scenario, a Public key would be the set of such characters.

A public key would have been generated using cryptographic protocols or the techniques, which contains asymmetric keyword encrypted methods.These very same keys were being used to convert a memorandum or manuscript to such an unintelligible state. Decryption has always been accomplished solely through the use of a completely separate, but associated, highly classified address and otherwise key.

Thus the above response is correct.

Learn more:

https://brainly.com/question/20709892

Other Questions
In a short paragraph, describe the history and characteristics of Oklahoma City. You can save money by: buying high quantities of perishable foods shopping locally cutting back on high quantities of meat in recipes like stews or soups buying name brand products Find the slope and y-intercept of the graph of 3y = 6x 12.The slope isand the y-intercept is Find the value of x for each function when f(x) = 24 Help me solve this problem please The number of visits to public libraries increased from 1.3 billion in 1994 to 1.6 billion in 1999. Find the average rate of change in the number of public library visits from 1994 to 1999. Fill in the blank in the following sentence with the appropriate future tenseform of the verb estudiar below.Yo____en la universidad.A. estudiarB. estudioC. estudiabaD. estudie X2+ ?x + 36ayoooo i need helppp Which of the following is true about achieving intellectual wellness?A. A person will be able to form reasonable opinions and share them.B. A person must be willing to learn new ideas.C. A person will have an awareness and appreciation of their own uniqueness. D. all of the above 10. What is the area of a triangle with base 4cm andheight 8cm?A. 6cm2 B. 9cm2 C. 14cm D. 16 cm In the sentence:I think I just got... an idea!the ellipsis is most likely used to show:Select one:1an unfinished thought.2a dialogue that ends with silence.3an omission in a quotation.4a pause in speech. compare the graph of g(x)=6x5 to the graph of f(x)=6xa. g(x) shifted up 5 unitsb. g(x) shifted down 5 unitsc. g(x) is 6 units steeperd. f(x) shifted down 5 units Sodium-24 has a half-life of 15 hours. When will 4 mg of Sodium-24 remain if the original sample contains 64 mg? FREE 50 POINTS Why is it important to live for today? i need 500 word essay ASP change from word to standard form sixty-seven and five hundred thirteen thousandths Question: In history the Mongols are remembered as "savage ruthless barbarians." Is this representation accurate? Using the terms stereotype, xenophobia, or prejudice explain why this representation is or is not accurate. Write your response in a claim, evidence, reasoning paragraph with a focus on your concluding sentence. See rubric below for more details. The zoo needs to hire b staff members for each exhibit. Write the expression forthe number of staff members they need to hire for 20 exhibits. I got a hair cut that I did not wanted but my parents did. Can some one give me tips or tell me a way to make my hair grow faster? living------is scaleless i hagfishes ii sharks iii bony fishes iv ostracoderms Study the Lewis dot diagram for nitrogen. Explain what is correct and what is incorrect about the diagram. Use details to support your answer.