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
[1] Our son has started playing organized T-ball, a beginner’s version of baseball. [2] “Organized” is what parents call it, any
k0ka [10]
I think it is 3 no? Maybe I dunno but I am confident
6 0
3 years ago
Read 2 more answers
One of the major advantages of digital photography is the ability to see the shot as soon as you take it.
FrozenT [24]
A. most cameras will let you see the shot you took for a second afterwards witch allows you to see errors like motion blur,focus,white balance and other things. 
3 0
3 years ago
Help Asap! Marking brainliest!✨
gulaghasi [49]

Answer:

The answer would be After the slide you are viewing.

I hope this helped!

8 0
3 years ago
Read 2 more answers
I will give Brainliest to the best answer, I need urgent HELP
laila [671]
The answer is B. Range
4 0
3 years ago
It takes you 0.8 of a minute to read each page of your health book. It takes you 5.5 minutes to take the test at the end. How lo
NeTakaya
The answer would be 13.3125 because 6.25 / 0.8 is 7.8125 than add 5.5 which will equal 13.3125. I'm sure about this.
7 0
3 years ago
Read 2 more answers
Other questions:
  • Again, consider what you believe to be the goal of performing a penetration test. Why would you worry about doing any privilege
    14·1 answer
  • 2. Now write a program named filereader.py that reads and displays the data in friends.txt. This program should also determine a
    5·1 answer
  • Word 2013 in order to share a document online you must first
    10·1 answer
  • According to Fourman, Informatics is _______________ with a very _____________ scope.
    5·2 answers
  • The term "Cloud" refers to what option(s) below? (Select all that apply)
    13·1 answer
  • Write down the bit pattern in the fraction of value 1/3 assuming a floating point format that uses Binary Coded Decimal (base 10
    10·1 answer
  • Which statement describes Augmented Reality (AR) technology?
    12·1 answer
  • What is the value of numX when this program is executed? if 3 < 5 and 8 != 3: numX = 3 else: numX = 7
    13·2 answers
  • In numpy to append two arreys vertically the function __ is used
    12·2 answers
  • Is each of the following method identifiers (a) legal and conventional, (b) legal but unconventional, or (C) illegal?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!