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
Anna has a physical mobility difference, and she uses virtual reality to complete her exercises. To use virtual reality, Anna ne
Zepler [3.9K]

Answer:

Explanation:

The basic concept of virtual reality is that they are a pair of lenses in a headset that allows you to visualize a virtual 3D world and become immersed within it. To do the exercises correctly Anna would need to follow the following basic steps.

Put the virtual glasses over her eyes, complete the exercises in the virtual world, take the virtual glasses off

The headset/glasses need to fit comfortably on her eyes and around her head so that she can clearly see the image on the lenses and so that the headset/glasses do not fall off while she is completing her exercises. Once she is done with her exercises Anna can simply take off her virtual glasses and put them away.

5 0
2 years ago
Technician A says that the purpose of the electrolyte is to allow the escape of hydrogen gas from the battery. Technician B says
kifflom [539]

Answer:

D. Neither Technician A nor B.

Explanation:

D. Neither Technician A nor B.

The electrolyte is a chemical medium that allows the flow of electrical charge between the cathode and anode. When a device is connected to a battery — a light bulb or an electric circuit — chemical reactions occur on the electrodes that create a flow of electrical energy to the device.  

7 0
3 years ago
A dietician wants you to write a program that will calculate the number of calories a person can lose by walking at a slow pace
gregori [183]

Answer:

The pseudocode is as follows

1. Input Steps

2. Input Day

3. Miles = Steps/2000

4. Calories = 65 * Miles

5. Print Calories

6. Stop

Explanation:

This line gets the number of steps for the day

1. Input Steps

This line gets the current day

2. Input Day

The line calculates number of miles

3. Miles = Steps/2000

This line calculates the calories lost

4. Calories = 65 * Miles

This line prints the calories lost

5. Print Calories

The pseudocode ends here

6. Stop

6 0
3 years ago
2.Any new class you create from an existing class is called a(n) ____.
trasher [3.6K]

Answer:

derived class

Explanation:

8 0
2 years ago
Write an algorithm and a C++ program that determines the change to be dispensed from a vending machine. An item in the machine c
hoa [83]

Answer:

// program that implement the algorithm to find the change.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

   // variables

   int cost,q,d,n,p;

   cout<<"Enter the cost of item between 25 cents and a dollar, in 5 increments (25, 30, 35, … , 90, 95, or 100):";

   // read the cost

   cin>>cost;

   // find the change

   int change=100-cost;

   // find quarter

   q=change/25;

   change=change%25;

   // find the dimes

   d=change/10;

   change=change%10;

   // find the nickels

   n=change/5;

   // find the pennies

   p=change%5;

   // print the change

   cout<<"Your change is: "<<q<<" quarter,"<<d<<" dimes,"<<n<<" nickels and "<<p <<" pennies."<<endl;

return 0;

}

Explanation:

Read the cost of item from user and assign it to variable "cost".Then find the change to be returned to user.Then find the quarter by dividing the change with 25.Update the change and then find the dimes by dividing change with 10.Then update the change and find nickels and then find the pennies.Print the change to be returned.

Output:

Enter the cost of item between 25 cents and a dollar, in 5 increments (25, 30, 35, … , 90, 95, or 100):45

Your change is: 2 quarter,0 dimes,1 nickels and 0 pennies.

8 0
3 years ago
Other questions:
  • The ____________ protocol enables two users to establish a secret key using a public-key scheme based on discrete logarithms
    10·1 answer
  • Ximena noticed that Sofia had created a network bridge on her new laptop between the unsecured wireless network and the organiza
    15·1 answer
  • An _________ is a phrase formed from the first letters of words in a set phrase or series of words a. Acronymic sentence c. Basi
    7·2 answers
  • Suppose you were assigned to develop a logical model of the registration system at a school or college. would you be better off
    9·1 answer
  • For window 7 explain the steps you will use to find the available program you will list.
    13·1 answer
  • A function test() that would take three integervalues x, y and z (as
    6·1 answer
  • Which is not one of the four criteria for proving the correctness of a logical pretest loop construct of the form: while B do S
    14·1 answer
  • Referat noaptea la școala cu sfârșit de groază​
    10·1 answer
  • The act of illegally copying software, music,or movies that are copied protect?
    7·2 answers
  • Why is the Microsoft website considered the best source for information about pagefile.sys?​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!