1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Setler79 [48]
3 years ago
13

Write a program that asks the user for the name of a file. The program should display the contents of the file with each line pr

eceded with a line number followed by a colon. The line numbering should start at 1. (You can create a file and populate it with some data, then run your program to open that file and display the contents line by line with the number of the line preceding the line data)
Computers and Technology
1 answer:
timofeeve [1]3 years ago
5 0

Answer:

Explanation:

The following program is written in Python. It asks the user for the file name (which needs to be in the same directory as the program) and reads the file. It then splits it by lines and saves it into an array. Then it loops through the array, printing each line with its corresponding line number.

file_name = input("File Name: ")

f = open(file_name, 'r')

lines = f.read().split('\n')

for line in lines:

   print(str(lines.index(line) + 1) + ': ' + line)

You might be interested in
windows 10 brought back the desktop, and gives the option to use either the start screen or desktop with a new tiled___
levacccp [35]

Answer:



A new tiled background

5 0
3 years ago
What can be designed to create annoying glitches or destoey data?...
daser333 [38]

WELL YOU ARE RIGHT its virus

hope it helps

3 0
4 years ago
Read 2 more answers
Which string method returns true if the character is a lowercase letter?
Vedmedyk [2.9K]

Answer:

Option 2, letter.islower() is correct

Explanation:

letter.islower() returns true when the string "letter" is lowercase.

3 0
3 years ago
What kind of skills does an electronics engineering tech need as requirement in the workplace?
eduard

Answer:

Electrical and electronics engineering technicians should also possess the following specific qualities: Logical-thinking skills. Electrical and electronics engineering technicians must isolate and then identify problems for the engineering staff to work on. They need good reasoning skills to identify and fix problems.

Explanation:

3 0
3 years ago
. What is suboptimization?
Vera_Pavlovna [14]

Answer: Suboptimization is referred to as a term that has been approved for common policy mistake. It usually refers to the practice of concentrating on a single component of a whole and thus making changes which are intended towards improving that component and also ignoring its effects on other components.

3 0
3 years ago
Other questions:
  • Sleeping is an effect of _______ , but agitation may cause a person to wake up
    7·2 answers
  • These systems consist of interlinked knowledge resources, databases, human experts, and artificial knowledge agents that collect
    9·1 answer
  • Code a Boolean expression that tests if a decimal variable named currentSales is greater than or equal to 1000 or a Boolean vari
    11·1 answer
  • Technician A says underinflation of a tire causes excessive one-sided wear on one side of the tread. Technician B says overinfla
    11·2 answers
  • How would a designer interpret the word denier?
    12·2 answers
  • 14. Which of the following statements is true? A. The most secure email message authenticity and confidentiality isprovided by s
    11·1 answer
  • PLEASE HELPP!!!!!
    14·1 answer
  • The NFiPA 704 system uses a numerical value between _____ and _____ to indicate the level of hazard for that particular chemical
    6·2 answers
  • Which of these is NOT an input device?
    14·1 answer
  • Which of the following statements is false? A. The internet has developed at a consistent rate throughout the world. B. There ar
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!