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
Solve the equation w - 2 = -3<br><img src="https://tex.z-dn.net/?f=w%20%3D%20%20%20-%20%20%5Cfrac%7B3%7D%7B2%7D%20" id="TexFormu
Andreyy89
Heres my answer w= -1
4 0
3 years ago
Give two examples of desktop publishing software
soldier1979 [14.2K]
There are quite a lot of desktop publishing software as of today.
I'll give you the names of some of it.
- Adobe inDesign - one of the most popular
- Corel Draw
- Microsoft Publisher
- Serif
- Ultra Xml
And more.
There are actually a lot if you are just about to check in the internet.
7 0
4 years ago
Which of the following correctly describes rules for setting up a Web file structure?
kramer

Forward slashes (/) are used for web address and backslashes (\) are used for file paths is the following correctly describes rules for setting up a Web file structure.

<u>Explanation:</u>

For a way to a nearby document on a Windows machine, utilize the backslash. For a way to a web asset or record situated on a UNIX based machine (incorporates Macs, Linux), use a slash.

The explanation .NET's URI utilizes forward slashes is on the grounds that it's arranging for use in an internet browser. at the point when a slash is utilized in a formal or casual book, it is intended to show the word or. The models show the importance of the forward-slash.

4 0
3 years ago
Keeping memos on your checks is important because they
Anastasy [175]

Answer: they can determine how you get paid, so if you get a memo about schedules, and you work hourly, you keep keep that memo to show that you are following direction in hours, which result in getting paid more/less.

8 0
3 years ago
Write a function PrintShampooInstructions(), with int parameter numCycles, and void return type. If numCycles is less than 1, pr
PSYCHO15rus [73]

// Writing a C++ function

void PrintShampooInstructions(int numCycles){

if(numCycles < 1) // if  condition stands

cout<< "To few";

else if(numCycles >4)

cour<<"Too Many";

else{

// looping the variable for desired out put

for(int i=0;i<numCycles;i++)

cout<<i<<":"<<" Lather and rinse."<<endl;

}

}

6 0
3 years ago
Read 2 more answers
Other questions:
  • Once the technology for the collection of solar power is in place what will be two benefits of its use
    9·1 answer
  • âwhat service uses a private cloud in conjunction with a web browser or downloaded client software to access desktop software?
    10·1 answer
  • Which of the following is an example of a wanted versus I need
    5·1 answer
  • Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive.
    8·1 answer
  • A new repair technician reports that he or she is having trouble installing the operating system. The problem arises when he or
    5·2 answers
  • Hello there!I have a Macbook Air and by accident I had put my finger on the screen and made a small white dot.
    8·2 answers
  • Write an algorithm which gets a number A, if it is even, prints even, and if it is odd prints odd.
    7·1 answer
  • This document shows a student's education and career goals and a way to achieve those goals.
    8·1 answer
  • What is the command to display the user name with which youhave logged in?
    8·1 answer
  • Show a parse tree and a leftmost derivation for : B = C * (A + B)
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!