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
Unwanted emails are called:malware,phishing, spam or virus
Colt1911 [192]
1. Spam
2. Phishing
3. True
3 0
3 years ago
Consider a set of mobile computing clients in a certain town who each
poizon [28]

Answer: answer given in the explanation

Explanation:

We have n clients and k-base stations, say each client has to be connected to a base station that is located at a distance say 'r'. now the base stations doesn't have allocation for more than L clients.

To begin, let us produce a network which consists of edges and vertex

Network (N) = (V,E)

where V = [S, cl-l, - - - -  cl-n, bs-l - - - - - - bs-k, t]

given that cl-l, - - - - - cl-n represents nodes for the clients

also we have that bs-l, - - - - - bs-k represents the nodes for base station

Also

E = [ (s, cl-i), (cl-i,bs-j), (bs-j,t)]

(s, cl-i) = have capacity for all cl-i (clients)

(cl-i,bs-j) = have capacity for all cl-i  clients & bs-j (stations)

⇒ using Fond Fulkorson algorithm we  find the max flow in N

⇒ connecting cl-i clients to  bs-j stations

      like (cl-i, bs-j) = 1

   if f(cl-i, bs-j)  = 0

⇒ say any connection were to produce a valid flow, then

if cl-i (clients) connected                f(s,cl-i) = 1 (o otherwise)

if cl-i (clients) connected  to bs-j(stations)   f(cl-i,bs-j) = 1 (o otherwise)

   f(bs-j,t) = no of clients  (cl-i)  connected to bs-j

⇒ on each node, the max flow value (f) is longer than the no of clients that can be connected.

⇒ create the connection between the client and base station i.e. cl-l to base bs-j iff    f(cl-i, bs-j) = 1

⇒ when considering the capacity, we see that any client cannot directly connect to the base stations, and also the base stations cannot handle more than L clients, that is because the load allocated to the base statsion is L.

from this, we say f is the max no of clients (cl-i) that can be connected if we find the max flow, we can thus connect the client to the base stations easily.

cheers i hope this helps

5 0
3 years ago
A series circuit and identify how voltage is split up by each load in the circuit?
Vlada [557]

The same current flows through each part of a series circuit. The total resistance of a series circuit is equal to the sum of individual resistances. ... The voltage drop across a resistor in a series circuit is directly proportional to the size of the resistor. If the circuit is broken at any point, no current will flow.

4 0
3 years ago
A linear gradient can be positioned from left to right, top to bottom, or on any angle?
Harman [31]

from left to right because it is used more in expressions

3 0
2 years ago
Write the name of test for the given scenario. Justify your answer.
Snowcat [4.5K]

Answer:

Cevap b okey xx

Explanation:

Sinyorrr

8 0
3 years ago
Other questions:
  • HELP I don't understand this
    14·2 answers
  • Write a Python program that gets a single character from the user and writes out a congratulatory message if the character is a
    9·1 answer
  • To change the overall design of an entire document to include colors, fonts, and effects, a user should apply a?
    8·2 answers
  • Analytical processing uses multi-levelaggregates, instead of record level access.? True? False
    12·1 answer
  • Consider the following statements: #include #include class Temporary { private: string description; double first; double second;
    9·1 answer
  • Given the variable ip, already declared as a pointer to an integer, write the code to dynamically allocate memory for a single i
    15·1 answer
  • What do you think is the most fascinating aspect of the internet?
    7·2 answers
  • What is the term used to describe the basic unit of data passed from one computer to another
    14·1 answer
  • Please help!!!! will mark brainliest!!
    7·2 answers
  • Helppppppppppp please
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!