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.txt and the contents of file1.txt are: 20 Gunsmoke 30 The Simpsons 10 Will & Grace 14 Dallas 20 Law & Order 12 Murder, She Wrote the file output_keys.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.

Answers

Answer 1

A programme that uses the file.readlines() function to read input files after reading the name of the file as its first move.

fileName = input("Please enter the name of the input file: ")

# Open and read the file

with open(fileName) as f:

   content = f.readlines()

# Initialize the empty dictionary

seasonDict = {}

# Populate the dictionary with contents of the file

for line in content:

   line = line.strip().split()

   numSeasons = int(line[0])

   showName = line[1]

   if numSeasons in seasonDict:

       seasonDict[numSeasons].append(showName)

   else:

       seasonDict[numSeasons] = [showName]

# Sort the dictionary by key (number of seasons)

sortedByKey = sorted(seasonDict.items(), key=lambda x: x[0])

# Output the dictionary by key to output_keys.txt

with open("output_keys.txt", "w") as f:

   for key, value in sortedByKey:

       f.write("{0}: {1}\n".format(key, "; ".join(value)))

# Sort the dictionary by value (alphabetical order)

sortedByValue = sorted(seasonDict.items(), key=lambda x: x[1])

# Output the dictionary by value to output_titles.txt

with open("output_titles.txt", "w") as f:

   for key, value in sortedByValue:

       f.write("{0}\n".format("; ".join(value)))

What is program?
An instruction set for a computer is known as a programme. It is a set of instructions and operations that, when used together, will result in a particular outcome. Programming languages like C++, Python, or Programming languages are used to create programmes, which can be anything from straightforward commands that do a single task to intricate systems that manage entire networks. The foundation of computer technology and a necessity in the modern world are programmes.

To learn more about program
https://brainly.com/question/26134656
#SPJ4


Related Questions

RAM IS often referred
to as
1 SECONDARY STORAGE
2 . READ ONLY MEMORY
3. RATIO ACTIVE MEMORY
4. PRIMARY STORAGE

Answers

Answer:

ratio active memory

Explanation:

ratio active memory because the rule of computer

Parts arrive at a two-machine system according to an exponential interarrival distribution with mean 20 minutes. Upon arrival, the parts are sent to Machine 1 and processed. The processing-time distribution is TRIA (4.5, 9.3, 11) minutes. The parts are then processed at Machine 2 with a processing-time distribution as TRIA (16.4, 19.1, 20.8) minutes. The parts from Machine 2 are directed back to Machine 1 to be processed a second time (same processing-time distribution but an independent draw from it). The completed parts then exit the system. Run the simulation for a single replication of 20,000 minutes to observe the average number in the machine queues and the average part cycle time with Arena Model

Answers

Answer:

I really don’t know computer science but I give u good luck in finding an answer to this question.

Explanation:

The code below assigns the 5th letter of each word in food to the new list fifth. However, the code currently produces errors. Insert a try/except clause that will allow the code to run and produce of list of the 5th letter in each word. If the word is not long enough, it should not print anything out. Note: The pass statement is a null operation; nothing will happen when it executes.
food = ["chocolate", "chicken", "corn
fifth = []
for x in food:
fifth.append(x[4])

Answers

Answer:

Answered below

Explanation:

foods = ["chocolate", "chicken", "corn"]

fifth_char = []

for food in foods:

"""Add a try statement to add fifth character to fifth_char list. If word is not long enough, the except part executes the the pass and nothing is printed.""'

try:

fifth_char.append(food[4])

except:

pass

#print out elements in new list

for c in fifth_char:

print(c)

Need to compress this IPv6 Address
ad93:a0e4:a9ce:32fc:cba8:15fe:ed90:d768

Answers

I can't underatnd your question

SORRY

Use the drop-down menus to describe how to add a data bar to a report.
1. Open the table in view.
2. Click the column of the desired numerical field.
3. Click the conditional tab Format, then .
4. In the Rules Manager dialog box, click .
5. Select to “compare to other records,” and determine whether you want the value and bar to show at the same time.
6. Adjust the desired length of the bar and the color. Click OK.
7. Once satisfied with your rule, click and then OK.

Answers

Answer:

1. layout

3. conditional formatting

4. new rule

7. apply

Explanation:

just did it on edge

Which of the following describes the line spacing feature? Select all that apply. adds space between words adds space between lines of text adds space between paragraphs adds space at the top and bottom of a page adds bullet points or numerical lists

Answers

Answer:

adds space between lines of text

adds space between paragraphs

Explanation:

g Write an UPDATE statement that changes the address for the row with vendor_id 4 so the suite number (Ste 260) is stored in vendor address instead of vendor address 1. Then, use SQL Developer to verify the change (you may need to click the Refresh button at the top of the Data tab to see the change). If this works correctly, go back to the tab for the UPDATE statement and click the Commit button to commit the change.

Answers

Answer:

UPDATE 'Vendors' SET 'address' = 'Ste 260' WHERE 'vendor_id' = 4

Explanation:

Required

Write an update statement

The question is incomplete as the table name is not given.

So, I will make the following assumptions.

Table name = Vendors

So, the update statement is:

UPDATE 'Vendors' SET 'address' = 'Ste 260' WHERE 'vendor_id' = 4;

The above statement queries the vendors table and changes the address  of vendor_id 4 from the initial value to Ste 260

What is a font?
O How the text for a paragraph appears
O A display of text characters in a specific style and size
O Text that has been made bold
O Artistic elements you can add to text

Answers

A display of text characters in specific style
answer: a display of text characters in a specific style and size

Use the drop-down menus to explain how to locate the Consolidate dialog box.

1. Select the ------------
tab on the ribbon.

2. Look in the ----------
group and select -----------
.

Answers

Answer:

data, data tools, consolidate

Explanation:

I just did it :)

I would select Straight 2-way Merge sort over Quick sort when which of the following are true.
A. Incorrect selections will be penalized.
B. If I knew that the distribution of the data was significantly skewed.
C. If space were not an issue If I knew the size of the data set was very large.
D. If I knew that the data tended to be in order.

Answers

Answer:

I would select Straight 2-way Merge sort over Quicksort when:

C. If space were not an issue If I knew the size of the data set was very large.

Explanation:

For large datasets, the Straight 2-way Merge sort has been found to be more efficient than the Quicksort.  It also works faster than Quicksort.  However, Quicksort has been found to be more efficient, working faster than the Straight 2-way Merge sort with small datasets.  The two are algorithms for sorting.  While Straight 2-way Merge Sort uses two streams with repetitions, the Quicksort uses just one stream without repetitions and additional storage space.

Consider the following recursive method.

public static String doSomething(String str)
{
if (str.length() < 1)
{
return "";
}
else
{
return str.substring(0, 1) + doSomething(str.substring(1));
}
}
Which of the following best describes the result of the call doSomething(myString) ?

A
The method call returns a String containing the contents of myString unchanged.

B
The method call returns a String containing the contents of myString with the order of the characters reversed from their order in myString.

C
The method call returns a String containing all but the first character of myString.

D
The method call returns a String containing only the first and second characters of myString.

E
The method call returns a String containing only the first and last characters of myString.

Answers

Answer:

A

The method call returns a String containing the contents of myString unchanged.

Explanation:

what should be at the top of a tower​

Answers

Answer:

mini part. a model cellphone tower

Design a program that asks the User to enter a series of 5 numbers. The program should store the numbers in a list then display the following data: 1. The lowest number in the list 2. The highest number in the list 3. The total of the numbers in the list 4. The average of the numbers in the list

Answers

Answer:

The program in Python is as follows:

numbers = []

total = 0

for i in range(5):

   num = float(input(": "))

   numbers.append(num)

   total+=num

   

print("Lowest: ",min(numbers))

print("Highest: ",max(numbers))

print("Total: ",total)

print("Average: ",total/5)

Explanation:

The program uses list to answer the question

This initializes an empty list

numbers = []

This initializes total to 0

total = 0

The following loop is repeated 5 times

for i in range(5):

This gets each input

   num = float(input(": "))

This appends each input to the list

   numbers.append(num)

This adds up each input

   total+=num

   

This prints the lowest using min() function

print("Lowest: ",min(numbers))

This prints the highest using max() function

print("Highest: ",max(numbers))

This prints the total

print("Total: ",total)

This calculates and prints the average

print("Average: ",total/5)

Write the mostValuableNeighbor method, which compares the item in row r and column c to the items to its left and to its right. The method determines which of the three items has the greatest value and returns its name. If more than one of the values have a value that is greatest, then any of their names can be returned. If the item has no item to its left, it is compared only to the item to its right. If the item has no item to its right, it is compared only to the item to its left.

Answers

Answer:

Explanation:

The following method is written in Java, using the Item class and ItemGrid class found online we can use this method to grab the 2-dimensional array and compare the three neighbors in the same row. It saves the position of the neighbor with the greatest value in the variable greatest and then uses that position to call the getName() method from the object in that position to get the name of that Neighbor and returns the name.

public String mostValuableNeighbor(ItemGrid grid, int r, int c) {

       int greatest = grid[r][c];

      if (grid[r][c+1].getValue() > greatest.getValue()) {

          greatest = grid[r][c+1];

      }

       if (grid[r][c-1].getValue() > greatest.getValue()) {

           greatest = grid[r][c-1];

       }

       

      return greatest.getName();

   }

In this exercise we have to use the knowledge of computational language in JAVA to write the code.

We have the code in the attached image.

The code in Java can be found as:

public String mostValuableNeighbor(ItemGrid grid, int r, int c) {

      int greatest = grid[r][c];

     if (grid[r][c+1].getValue() > greatest.getValue()) {

         greatest = grid[r][c+1];

     }

      if (grid[r][c-1].getValue() > greatest.getValue()) {

          greatest = grid[r][c-1];

      }

     return greatest.getName();

  }

See more about JAVA at brainly.com/question/26104476

Write a modular program that accepts up to 20 integer test scores in the range of 0 to 100 from the user and stores them in an array. Then main should report how many perfect scores were entered (i.e., scores of 100), using a value-returning countPerfect function to help it. Hint: Have the program count the scores as they are entered. Your program may need this information later.

Answers

Answer:

The program in Java is as follows:

import java.util.*;

public class Main{

public static int countPerfect(int [] scores, int n){

    int count = 0;

    for(int i = 0;i<n;i++){

     if(scores[i] == 100) {count++;}  }

 return count; }

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 int n;

 System.out.print("Number of scores: ");

 n = input.nextInt();

 if(n<1 || n>20){n=20;}

 int [] scores = new int[n];

 for(int i = 0;i<n;i++){

     scores[i] = input.nextInt();  }

 System.out.print("Perfect Scores: "+countPerfect(scores,n));  

}

}

Explanation:

The countPerfect function begins here

public static int countPerfect(int [] scores, int n){

This initializes the count to 0

    int count = 0;

This iterates through the array elements

    for(int i = 0;i<n;i++){

If current score is 100, count is incremented by 1

     if(scores[i] == 100) {count++;}  }

This returns the value of count

 return count; }

The main begins here

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

This declares the number of scores, n

 int n;

Prompt to enter the number of scores

 System.out.print("Number of scores: ");

This gets input for n

 n = input.nextInt();

If input is less than 1 or greater than 20, n is set to 20

 if(n<1 || n>20){n=20;}

This declares the scores as an array

 int [] scores = new int[n];

This iterates through the array and get inputs for each score

 for(int i = 0;i<n;i++){

     scores[i] = input.nextInt();  }

This calls the function and print the number of perfect scores

 System.out.print("Perfect Scores: "+countPerfect(scores,n));  

}

SHORT ANSWERS:

Q.1 List some causes of poor software quality?









Q.2 List and explain the types of software testing?


Q.3 List the steps to identify the highest priority actions?










Q.4. Explain the importance of software quality?

Answers

Answer:

Hard drive Microsoft have the highest priority actions

Make these negative sentences more positive and polite. Keep the meaning.

1.Don’t run for the bus. You might slip on the ice and fall
2.Don’t tell me what you can’t do.
3.Don’t eat with your mouth open.
4.Don’t submit an incomplete report.

Answers

Answer:

You should not run for the bus. You could slip on the ice and fall

Would you stop telling me what you can't do

Could you not eat with your mouth open

You should not submit an incomplete report

Answer:

You should not run for the bus. You could slip on the ice and fall

please stop telling me what you can't do.

please do not eat with your mouth open

you shouldn't submit an incomplete report. it could affect your grades negatively.

Explanation:

hope this helps!

~mina

Acróstico sobre mouse

Answers

this is a PICTURE

i HOPE IT'S HELP

Consider the following code snippet:
public static void print(E[] a)
{
for (int i = 0; i < a.length; i++)
{
System.out.println(a[i] + " ");
}
}
int[] a = {3,6,5,7,8,9,2,3};
print(makeArray(a));
Assume that the method call to print(makeArray(a)) works correctly by printing the int array a. Which of the following headers for the makeArray method will make this possible?
I public static Integer[] makeArray(int[] a)
II public static E[] makeArray(int[] a)
III public static Integer[] makeArray(E[] a)
I and III only
I only
I and II only
II and III only
What does it mean when the syntax ? extends D is used?
Any subclass of D may be used.
Any superclass of D may be used.
Any subclass or superclass of D may be used.
This indicates a wildcard with an upper bound.
Consider the following code snippet that declares the GraduateStudent class:
public GraduateStudent extends Student { . . .}
Which of these statements are false?
a. I GraduateStudent is a subclass of Student
b. II Stack is a subclass of Stack
c. III Stack is a subclass of Stack
d. II only
e. III only
f. II and III only
g. I only

Answers

Answer:

Explanation:

1) I and II only ... This is because the makeArray parameter must be an int[] since that is what the a array that is being passed actually is. The return type should be E[] only but since that is not an option, it could work with Integer[] if the E class allows.

2) Any superclass of D may be used. Although this is not complete, extends allows for a subclass to access any variables and methods within the superclass D but not directly access another superclass of D.

3)  I only ... GraduateStudent is a subclass of Student

LAB: Varied amount of input data
Statistics are often calculated with varying amounts of input data. Write a program that takes any number of integers as input, and outputs the average and max.
Ex: If the input is:
15 20 0 5
the output is:
10 20

Answers

Answer:

Answered below

Explanation:

#python program

#First get the number of inputs from user

num_inputs = int(input("Enter number of inputs:")

j = 0

sum =0

max = 0

while j < num_inputs:

    num = int(input ("Enter numbers: ")

    sum = sum + num

    if num > max:

        max = num

  j++

#Compute the average   

average = sum/num_inputs

print (average, max)

   

Which range of values would result in 10 elements stored in an array?

1-11

0-9

0-10

2-12

Answers

Answer:

0-9

Explanation:

count 0 as 1

len(0,1,2,3,4,5,6,7,8,9)=10

PLEASE HELP I REALLY NEED IT ASAP
Select the correct answer. Layla and her team have installed a fire alarm system in an office. The alarm system connects to a wireless network, so it can be monitored using smartphones and computers connected to the same network. Which wireless technology does the fire alarm system use?
OA satellite
OB. Bluetooth
O C. infrared
OD. WI-FI​

Answers

Answer:

wifi

Explanation:

if it's running on the same network that's wifi

Answer:

The correct answer is D. Wi-Fi.

Explanation:

I got it right on the Edmentum test.

there are several application to assist you to surf through the internet mention three regarding computer​

Answers

Answer:

E-mailweb browsingpeer-to peer services

From the philosophical standpoint, especially in the discussion of moral philosophy or ethics, why do we consider “murder” or “killing” wrong or bad?

Answers

Explanation:

Morality is a set of values ​​and habits that a society acquires over time and can be categorized as good and bad values, right and wrong, justice and crime. Ethics is defined as the study of morals, the practical application of moral behaviors defined by society.

Therefore, the concept of "murder" or "killing" is seen as an immoral act by the vast majority of society around the world, strengthened by the set of moral conduct common to all human beings, which are the Articles on the Universal Declaration of Human Rights. Human Rights, which is an official document of the UN, which contains several universair and analytical rules on the rights of every individual, such as the right to life, security, freedom, etc.

The Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13, ......., where each number is the sum of the two preceding numbers. Write a program that declares an array of length 15 and fills the array with the first 15 Fibonacci numbers. Print the array to check if the array elements are correct. Use the sizeofoperator instead of 15 whenever you need to use the array length.

Answers

0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597

Assume a manufacturing company which manufactures and sells several electronic
products. This company has a list of suppliers who supply various components for
different products. Several components assembled together form a product. A product
will be manufactured in many work centers. Each product contains several components.
A product has at least one component and may comprise of several components. A
component must belong to a product and the same component can be used in multiple
products. Also mention the quantity of the component which a product requires.
Company has a list of suppliers who supply various components. A supplier may not
be supplying any component and may supply several components. A component must
be supplied by at least one supplier or several suppliers may provide the same
component. A supplier supplies the quantity and unit price of the products. A supplier
also supplies the quantity and unit price of the components. Each product will be
manufactured in single or multiple work centers. A work center may not produce a
product and may produce several products. Each work center will have one or more
employees and an employee would be working in single work center only. A customer
may not place any order and may place multiple orders. But an order will belong to a
specific customer only. Each order may contain single product or multiple products and
the same product may be demanded in many orders.
Construct an ER diagram for the manufacturing company.

Answers

Answer:

reboot it

Explanation:

Derive the three-dimensional transformation matrix for scaling an object by a scaling factor s in a direction defined by the direction cosines alpha , beta , gamma

Answers

Answer:

i dont know

Explanation:

i dont knoe im doing this for the points hehe

What power points feature will you use to apply motion effects to different objects of a slide

Answers

Answer:

Animation scheme can be used to apply motion effects to different objects of a slide.

If you notice that a worksheet displays columns A, B, C, E, and F, what happened to column D?

Answers

Answer:

HUDSU

Explanation:WGSDBHEUIWDBWJJ

Reusing existing software to create a new software system or product can be a cost-efficient approach to development in many software projects. It may not be cost-efficient in all projects. As a software engineer, you can determine if it is the best approach for your project only if you know, and can estimate, the associated costs. Which of the following costs is NOT one of the costs typically considered when estimating the cost of reuse?
A. The purchase or license cost of COTS software, where applicable
B. Modification and/or configuration costs associated with making reusable software meet system requirements
C. The cost associated with finding analyzing, and assessing software for reuse
D. Legal costs associated with defending against charges of copyright infringement
E. Integration costs associated with mixing reusable software and other software (either new or reused)

Answers

Answer:

D. Legal costs associated with defending against charges of copyright infringement

Explanation:

When estimating the cost of reusing software you are planning to obtain the necessary licences that are required for your project which will prevent copyright infringement claims from taking place.

Other Questions
What European countries had the most land in Africa? how does intuition fit into the larger discussion of ocgnition? what does it mean that the intuition is often implicit What is the problem Swift is addressing? whoever helps get 13 pts ty sm Part A: In two or more sentences, explain what a variable expense is and provide at least two examples.Part B: In two or more sentences, explain what a fixed expense is and provide at least two examples. 3. Write < or > for each pair of numbers.-6.48 -6.55.983 5.993.09. 3.01 (100 points) Which sentences in the passage are true concerning a function?Which sentences in the passage are true concerning a function?A spreadsheet function takes values in the form of arguments, performs a calculation, and returns a result. All spreadsheet functions start with the hash sign (#). The arguments go inside angle brackets, < and >, and are always separated by colons (:). Instead of specifying constants as arguments, it generally makes more sense to use cell references. You can even specify a range of cells by using a comma (,) in place of a colon (:).I wont see this answer so no brainliest, just putting this question here to hopefully help someone in the future who needs a answer. This question is from epic. What are mutations in gametes called? What is the factor of x 13x 32x 20? Alyson is restocking her pantry. She buys 4 kinds of canned soup: tomato (T), mushroom (M), vegetable (V), and chicken noodle (N). She also buys garlic croutons (G) and cheese croutons (C) to pair with the soups. Which TWO statements are TRUE for this situation?A.{ T, M, V, N, G, C} is the sample space.B.{TG, TC, MG, MC, VG, VC, NG, NC} is the sample space.C.There are 8 serving combinations.D.{T, M, V, N} is the sample space.E.There are 6 serving combinations. Is a sister chromatid a DNA molecule? What major trends and developments are retailers facing? How do these developments impact their competitive strategies? In ____, when several activities need the same limited resource at the same time, the activities with the least slack have first priority.a. resource monitoring b. resource limited scheduling c. resource evaluation scheduling d. resource leveling PLS HELP WILL GIVE BRAINIEST!!! How do the authors support their claim and purpose? The stone thrown with an initial velocity of 20. meters per second straight upward from the edge of a cliff 100. meters above a canyon floor. The stone just misses the cliff's edge on its way down (Neglect friction). Calculate the position of the stone 6.0 seconds after it was thrown. What shape has 7 sides called? How do I become more aware of my thoughts? Quelques questions sur Jadis dans un autre pays de Conon de Bthune4. Au Moyen Age, l'amour courtois met en scne un chevalier amoureux d'une dameinaccessible. Montrez que ce pome reprend les codes de l'amour courtois, mais qu'illes dtourne de manire satirique.5. Montrez que ce texte est trs thtral.6. Expliquez comment procde le chevalier pour dfendre le carpe diem. What is it called when government spends more than it receives in taxes during a given year?