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
What is a flowchart​
serious [3.7K]

a diagram of the sequence of movements or actions of people or things involved in a complex system or activity.

4 0
2 years ago
AYYOOOO CAN YOU HELP A GIRL OUUTT???
goblinko [34]

Answer: The answer is true

8 0
2 years ago
HELPPP ME PLEASEEE!!
natita [175]
It’s the last one! The key to an effective persuasion is to know what you want and be clear about your response.
4 0
2 years ago
When using _____, developers are required to comply with the rules defined in a framework. (Points : 2) inheritance
Nikolay [14]

Answer: Contracts

Explanation:

The contract is the mechanism which is basically used by the developers to follow the set of rules that is defined in the framework with the proper specification in the API ( Application programming interface).

The contract is the proper agreement between the two and more developers so that they must follow the rules that is mentioned in the agreement contract.  

The contract is widely used in the software development process in which all the possible design requirement are mentioned according to the needs of the client.

Therefore, Contract is the correct option.

7 0
2 years ago
Each TextField has a text property that's returned by its textProperty method as a StringProperty. The StringProperty method ___
masha68 [24]

Answer:

B: Bind

Explanation:

JavaFX property binding permits the synchronization of the value of two properties in such a way that whenever there is a change in one of the properties, there is an immediate update on the value of the other property. In this way, The StringProperty method bind receives an ObservableValue as an argument. When the ObservableValue changes, the bound property is updated accordingly.

4 0
3 years ago
Other questions:
  • Show the contents of a queue after the following operations are performed. Assume the queue is initially empty. enqueue(45); enq
    6·1 answer
  • Home communication involves controlling systems such as heating, cooling, and security.
    11·1 answer
  • Which is the primary use of a word processor? create, edit, format, and print text-based documents maintain a database of record
    5·1 answer
  • A user wants to make sure he can quickly restore his computer after a drive failure to the state it was in when Windows and all
    9·1 answer
  • How are modern computers different from eniac?
    5·1 answer
  • Assume that the classes listed in the Java Quick Reference have been imported where appropriate.
    8·2 answers
  • Which party controlled the White House and politics in the late 1800s, except for Grover
    6·2 answers
  • Which of the following is a quick way to restore the arrow pointer after you have used it for drawing?
    5·1 answer
  • Which value can be entered to cause the following code segment to display the message "That number is acceptable."? ____.
    15·1 answer
  • Which types of computers are used by large businesses
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!