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]
2 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]2 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
IN EXCEL, File, menu , edit, insert are all located in ?
abruzzese [7]

Answer:

menu bar is the correct answer

hope it helps☺️

7 0
2 years ago
How can I download music and films at home without breaking the law?
mina [271]

Answer: use a legal music downloader

Explanation: :)

5 0
2 years ago
Read 2 more answers
Write a for loop that computes the following sum: 5+10+15+20+...+485+490+495+500. The sum should be placed in a variable sum tha
Strike441 [17]

Answer:

public class num9 {

   public static void main(String[] args) {

       int sum =0;

       int num =5;

       for(num =5; num<=500; num+=5){

           System.out.println(num);

           sum +=num;

       }

       System.out.println(sum);

   }

}

Explanation:

  • Declare and initialize the variables sum and num
  • Use a for loop with the condition for(num =5; num<=500; num+=5) Since the loop will increment by 5 and run from 5 to 500
  • Within the loop, add num to sum at each iteration
  • Print all elements on seperate lines
  • Outside the loop, print the final value of sum

Create a for loop

6 0
3 years ago
If you want to stop a loop before it goes through all of its iterations, the break statement may be used. Group of answer choice
NeX [460]

Answer:

Answer is true

Explanation:

6 0
1 year ago
*asap* Name one of the similarities between Word and Excel.
Yakvenalex [24]
The similarities are:  in both programs you can type letters, insert images, hyperlinks.
7 0
3 years ago
Other questions:
  • An Open Authorization (OAuth) access token would have a _____ that tells what the third party app has access to
    5·1 answer
  • What are the TWO methods of copying and pasting on the AutoCAD Clipboard function?
    7·1 answer
  • Develop a C++ program that will determine whether a department store customer has exceeded the credit limit on a charge account.
    13·1 answer
  • Which is an example of an incremental approach to solving a problem?
    15·1 answer
  • If you notice files being transferred to or from your computer a. Simply close the window c. Tell the lab instructor b. Open a n
    11·2 answers
  • Do you have to make a account of Windows 10?
    12·1 answer
  • Can someone start me off with a short 2 or 3 paragraphs about the pros and cons of Microsoft Word, and if you can recommend a si
    12·1 answer
  • How to make a project using PID and thermacouple
    11·1 answer
  • Witch icon allows you to see paragraph formatting feature
    6·1 answer
  • In a computer-controlled greenhouse, a temperature sensor and a window motor are connected to the computer.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!