Write a program that first reads in the name of an input file and then reads the input file using the file.readlines() method

Answers

Answer 1

Using the computational language in python we have to use it to write to a file and read with the code.

Writing this code in python we have:

filename = input()

file = open(filename)

lines = file.readlines()

data = {}

for i in range(0, len(lines), 2):

   num_seasons = int(lines[i].strip())

   show = lines[i + 1].strip()

   if num_seasons not in data:

       data[num_seasons] = []

   data[num_seasons].append(show)

file.close()

file_writer = open('output_keys.txt', 'w')

titles = []

for num_seasons in sorted(data):

   shows = []

   for show in sorted(data[num_seasons]):

       titles.append(show)

   file_writer.write(str(num_seasons) + ': ' + '; '.join(data[num_seasons]) + '\n')

file_writer.close()

file_writer = open('output_titles.txt', 'w')

for title in sorted(titles):

   file_writer.write(title + '\n')

file_writer.close()

See more about python at brainly.com/question/18502436

#SPJ1

Write A Program That First Reads In The Name Of An Input File And Then Reads The Input File Using The

Related Questions

Wollongong City council is interested in the growing tourism market and opens an office to launch services for people who travel on holidays and cannot look after their properties (houses or units) while they are away. This new office currently has 200 employees whose PCs are linked by a small LAN. Each PC shares files and also services (such as printing) with the others on the LAN. What type of network model is suitable to build a small LAN for this new office? How can you protect your LAN from Malware attacks?

Answers

Answer:

list five characteristics of cpu

A continuous and differentiable function f(x) with the following properties: f(x) is decreasing at x=−5 f(x) has a local minimum at x=−2 f(x) has a local maximum at x=2

Answers

The continuous and differentiable function where f(x) is decreasing at x = −5 f(x) has a local minimum at x = −2 f(x) has a local maximum at x = 2 is given as: y = 9x - (1/3)x³ + 3.

What is a continuous and differentiable function?

The continuous function differs from the differentiable function in that the curve obtained is a single unbroken curve in the continuous function.

In contrast, if a function has a derivative, it is said to be differentiable.

What is the solution to the problem above?

It is important to note that a function is differentiable when x is set to a if the function is continuous when x = a.

Given the parameters, we state that

f'(5) < 0; and

x = -5

The local minimum is given as:
x = -3;

the local maximum is given as

x = 3

Thus, x = -3 ; alternatively,

x = 3.  With this scenario, we can equate both to zero.

Hence,

x + 3 = 0;

3-x = 0.

To get y' we must multiply both equations to get:

y' = (3-x)(x + 3)

y'   = 3x + 9 - x² - 3x

Collect like terms to derive:

y' = 3x - 3x + 9 - x²; thus

y' = 9-x²

When y' is integrated, the result is

y = 9x - (x³/3) + c

Recall that

F (-5) < 0

This means that:

9 x -5 - (-5³/3) + c < 0
⇒ -45 + 125/3 + c <0
⇒ -10/3 + c < 0

Collecting like terms we have:
c < 10/3; and

c < 3.33


Substituting C into

f(x) = 9x - x³/3 + c; we have

f(x) = 9x - x³/3 + 3, which is the same as  y = 9x - (1/3)x³ + 3.

Learn more about differentiable functions at:
https://brainly.com/question/15047295
#SPJ1

What is returned by the code: range (20, 100, 20)

Answers

The code that is returned by the code: range (20, 100, 20)  is known as  (20, 50, 80).

What is this code about code?

The line of code is known to be one that often returns the ASCII code as the ASCII is known as American Standard Code for Information Interchange.

Note that the code is made up of   seven bit code and thus the code returned for range (20, 100, 30) is (20, 50, 80).

Learn more about code from

https://brainly.com/question/20796198

#SPJ1

How can you tell if a website is biased?

Answers

Answer:

the author has not considered other points of view.

Other Questions
Your wealthy uncle established a $2,100 bank account for you when you were born. For the first 9 years of your life, the interest rate earned on the account was 4%. Since then, rates have been only 2%. Now you are 23 years old and ready to cash in. How much is in your account Name the force acting on the handles of a plastic shopping bag that is full of groceries. Choose the best answer. Which of the following grows on a tree?el cerdoel pollola fresala cereza Mrs. Hyde is the art teacher at Washington Elementary School. She is hanging her students' artwork on one of the walls in the school hallway. Use the clues to determine in which order the artwork is being hung, from left to right. The third graders are to the left of the fourth graders. The second graders are between the fifth graders and the third graders. Automated External Defibrillators should only be used when...O Victim is chokingO Victim is alert but has difficulty breathingO Victim has collapsed with no pulse PLEASE HELP ASAP ILL MAKE YOU THE BRAINIEST Find the area of the rhombus What is the scale factor for XYZ TO UVW? please help me im just really slow ( PLEASE HELP WILL MARK BRAINLIEST PLEZ ) Calculate the area of a triangle with a base of 6 cm and a height of 12 cm. Draw and label the triangle. Select the correct MLA citation format for a full novel."The Giver"The GiverThe GiverThe Giver You are building a brick patio. the length of the patio is (x+11) feet. the total area of the patio can be represented by x^2+14x+33. write an expression for the width of the patio Once i built a tower, up to the sun, brick, and rivet, and lime, once i built a tower, now it's done which reality of the great depression does the excerpt convey? stock market crash decreased demand for products increased unemployment lower agricultural production A nurse is collecting a specimen for an aerobic culture from a client who has draining pressure injury. identify the sequence of actions the nurse should take I kinda need an explanation on how to solve this. What is one difference in the way that enslaved people and indenturedservants were treated in colonial North America? 16-15-14-13-12-11-65Distance (meters)1698master bedroomliving room2nd bedroom.X0 1 2 3 4567 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 2Distance (meters)What is the area of the kitchen floor in this floor plan?6 5y432-0kitchenentry-bath The value of x is 50% more than the value of t. the value of y is 10% less than the value of w. x = y work out t/w 5. Study the table below. Which animal is probably the closest relative to the shark?Limbs are arms, legs, and wings. Mammary glands are used for feeding offspring with milk.hummingbirdhorsesnakelion What is the surface area in square inches of a basketball that has a diameter of 9 inches 13 (11 + 11) - (4 17) - 6 = X