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
Jlenok [28]
3 years ago
10

# q7 - create function readFileFirstLast() to meet the conditions below

Computers and Technology
1 answer:
MAVERICK [17]3 years ago
3 0

Answer:

See explaination

Explanation:

def readFileFirstLast(filename):

# doc string

''' Function accept the filename and opens the fle

and reads all lines and strips new line character and

stores first and last in a string and return that string'''

#eception handle if file not found

try:

#opening the file

f = open(filename)

#reading the first line and striping the ne line

string = f.readline().strip()

#iterating until last line

for line in f:

pass

#concate the last line after strip the new line character to the string

string = string + " " + line.strip()

#return the string

return string

except:

#if file not found

return "File not found"

#taking the file name from user

filename = input("Enter a file name: ")

#printing the doc string in function

print("\ndoc_sting: \n"+ readFileFirstLast.__doc__+"\n")

#printing the returned string by calling the readFileFirstLast()

print("output string :")

print(readFileFirstLast(filename))

You might be interested in
Help me with this question asap please :)
Svetradugi [14.3K]

Answer:

I think it's sequence as there is a pattern of connection in the words

8 0
2 years ago
Which term describes an event where a person who does not have the required clearance or access caveats comes into possession of
notka56 [123]

Answer:

The answer is "compromise"

Explanation:

In computer science, the comprised system is used to describe as any technological resource, that has been negatively affected by an untrustworthy source for nondisclosure, integrity or accessibility either deliberately or inadvertently.

  • In this, the mechanical interaction from the unauthorized source or technological progress can result in compromise.
  • This helps you and the partner to meet each other's interests by taking into consideration both the positions and the solution to the main problem.

4 0
3 years ago
Read 2 more answers
Are our current copyright policies helping society or hurting society? i need help
Oksanka [162]

Answer:

helping society

Explanation:

it can help you to protect your works and creativity and brilliant ideas from liars and cheaters and frauds

5 0
3 years ago
What is general charactersristics of the ethiopan physiograhy​
inessss [21]
The major physiographic features are a massive highland complex of mountains and plateaus divided by the Great Rift Valley and surrounded by lowlands along the periphery. The diversity of the terrain is fundamental to regional variations in climate, natural vegetation, soil composition, and settlement patterns.
8 0
2 years ago
Prior to the world wide web as we know it today, the internet was chaotic, without any ____.
atroni [7]
Search engines - there was no single way to ask a question
5 0
4 years ago
Other questions:
  • List five characteristics of a series circuit
    9·1 answer
  • teve wants to use Google Display Ads to reach new customers who are looking to purchase products similar to his. Which audience
    14·1 answer
  • Create a class called Home that contains 4 pieces of information as instance variables: county (datatype string), street (dataty
    5·1 answer
  • T.J. wants to send a friend a file with a funny dancing cat. Which file format should T.J. use?
    13·2 answers
  • 7.4.1C The global distribution of computing resources raises issues of equity, access, and power. Briefly describe one of these
    11·1 answer
  • Can anyone help me<br> I will make you a brainalist
    13·1 answer
  • When the continue statement is encountered in a loop, all the statements in the body of the loop that appear after it are ignore
    5·1 answer
  • Assignment 2 edhesive
    8·2 answers
  • Write the code (from to )using for loop andif elseif statementto accept themobile phone numbersof200 residents of Dubaiasstringa
    15·1 answer
  • How does a file reader know where one line starts and another ends?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!