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
tia_tia [17]
3 years ago
14

Write a shell (text-based) program, called first_word.py, that opens the file stuff.txt and prints out the first word of every l

ine except the first line.
For example, if stuff.txt has the following sentences:

We are hungry.
There is an apple.
There is an orange.
Now we are thirsty.
Then the following example output would happen.

PS C:\Users\ssiva\Desktop> python first_word.py
There
There
Now
PS C:\Users\ssiva\Desktop>
Computers and Technology
1 answer:
postnew [5]3 years ago
3 0

Answer:

See explaination

Explanation:

Please check below for the code for first_word.py file which will print first word of an input file stuff.txt. So the open function will open file in read mode. We had maintained a count variable so that we can skip printing first word of first line. Also the command line.strip() checks whether string is empty or not so that we will not get index error while calling split function over line to get first word.

#!/usr/local/bin/python

stuff = open("stuff.txt", "r");

count = 0;

for line in stuff:

count+=1;

if (count>1 and line.strip()):

print(line.split(maxsplit=1)[0])

You might be interested in
What type of software testing is generally used in Software Maintenance?
zvonat [6]

Answer:

Regression Testing

Explanation:

6 0
2 years ago
You are an interior decorator, confronted with a dark living room. To lighten the room up, you have n candles and want to build
user100 [1]

Answer:

a)

Algorithm to find a solution of min. cost

Function:cost(Graph G,Graph G1);

GC --> empty graph

for i in edges E:

if E(i,j) in G:

c(i,j)=c(i,j)

else if E(i,j) in G1:

c(i,j)=-c(i,j)

Function:Mincost(Graph G):

GC=Cost(G,G1)

while(negativecycle(GC)):

Update residal graph(G1)

GC=Cost(G,G1)

mincost=sum of Cij*F(i,j)

return mincost;

Explanation:

a)

1) Start the program

2) Read the no. of edges and vertices and also read the cost of the two nodes.

3) Find the min cost by travelling to the destination i.e.. finding all possible min. cost values.

4) Compare the all possible min.cost values

5) And display the least min. cost

6) Stop the program

b)

<u>Correctness of algorithm</u>

1)Here in these algorithm we are calculating all the possible cases.

2)These algorithm also supports the negative cost.

3)These algorithm occupies more space.

4)Takes less time

5)so,these algorithm provides the cost efficient solution very effectively.

c)

<u>Run Time Analysis</u>

1) While reading the values during the run time the program execution will stop until user provides the values.

2) Based on the User input Output vary.

3) Time consumption and space consumption is depends on the no. of inputs the user is given.

6 0
3 years ago
The United States Army retains a history of all equipment acquisition from approval of requirements through funding, authorizing
Mama L [17]

Answer:

A. data mart

Explanation:

Data mart refers to a structure for storing and retrieving data. Often times, the data mart is usually specific to a business line.

The data contained herein is also specific to a particular department and by so doing this facilitate easy isolation, use and development of the data.

The major advantage of creating data marts is for easy accessibility of data.

7 0
3 years ago
A looping construct that continues to repeat until the expression becomes false is
Elis [28]

Answer:

a while loop

Explanation:

for an example, while x<4:

the program will end when the value of x greater than 4.

8 0
3 years ago
Read 2 more answers
List four tasks that humans perform frequently, but which may be difficult for a computerized agent to accomplish. Describe the
denis23 [38]

Answer:

im sorry for that

Explanation:

5 0
2 years ago
Other questions:
  • Help! live preview in brackets is not working
    8·1 answer
  • On the pie chart below, which “slice” represents 30% of the budget?
    8·1 answer
  • The smallest building block of a wireless lan is a ______.
    5·1 answer
  • What feature of a word processing program helps you to easily check and correct spelling mistakes?
    9·1 answer
  • What was the original motivation for developing the internet?
    7·1 answer
  • You are late in the preparation of the computer graphics for your final report and presentation. You run into a friend who is gr
    13·1 answer
  • Which of the following countries have mixed-market economy
    5·1 answer
  • How many total cells can a worksheet window contain? If columns are labelled alphabetically, what will be the label for the cell
    15·1 answer
  • Write a python statement that print the number 1000
    6·1 answer
  • What is the most used gaming keyboard in 2022?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!