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
Which is NOT a type of SD card?
andre [41]
I'm pretty sure the answer is B.

SD SC can held up to 2GB capacity

SDHC can held up to 32 GB

SDXC (eXtended) can held up to 2TB

SDIO is an interface for I/O devices, there are cameras with this standard.
6 0
3 years ago
Read 2 more answers
________ was one of the first uses of the Internet
NeTakaya

Government weapon in cold war

3 0
2 years ago
Read 2 more answers
Yo, my Lenovo laptop keeps showing this screen but I can't sign in, can someone help me?
rusak2 [61]
Break your laptop and get a new one
8 0
2 years ago
Read 2 more answers
Program 3.Study the code carefully and write out the line where there is error, debug it and write out the correct code
stich3 [128]

Answer:

Several errors:

  • 0 where ( ) was intended (probably OCR problem)
  • space between As and Double
  • Single quote in stead of double quote in text string
  • $ in stead of & near Math.sqrt
  • missing spaces around "is" for proper formatting

5 0
3 years ago
Software obtained illegally is called open-source software. true / false
Oxana [17]
False, software obtained illegally is called Pirated Software.
<span>Open source software is software developed by and for the user community, ie. Linux based software is Open Source.</span>
3 0
3 years ago
Other questions:
  • The ____ file permission category in unix/linux systems typically entails all permissions and is designated by the letter u.
    7·1 answer
  • Optimally, the __________ guides investment decisions and decisions on how ISs will be developed, acquired, and/or implemented.
    6·1 answer
  • Discuss three ways you could (or currently do) use the Excel software in your personal or professional life. Provide examples an
    12·1 answer
  • Match the terms with their definitions.
    5·2 answers
  • Program Rock.java contains a skeleton for the game Rock, Paper, Scissors. Open it and save it to your directory. Add statements
    10·1 answer
  • 0x400C (in hexadecimal)?
    8·1 answer
  • Write a program that estimates how many years, months, weeks, days, and hours have gone by since Jan 1 1970 by calculations with
    15·1 answer
  • Messages that have been accessed or viewed in the Reading pane are automatically marked in Outlook and the message subject is no
    10·2 answers
  • What operating system do most users use?
    13·1 answer
  • The first time that a particular visitor loads a web site page is called a(n) _____.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!