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
Savatey [412]
3 years ago
7

Write a Python function called readlinesmton that accepts the name of the file (i.e. filename), starting line number (i.e. m) an

d ending line number (i.e. n) as a parameter. The function then returns the contents from line number m to n (m < n). If m < 1 then start from line 1. Similarly, if n > number of lines the file, then stop at the last line in the file.
Computers and Technology
1 answer:
KatRina [158]3 years ago
5 0

Answer:

Following are the code to the given question:

def readlinesmton(filename, m ,n):#defining a method that holds three parameters

   f=open(filename, 'r')#defining f variable that holds open method

   l=f.readlines()#defining a variable l that readers input file

   e=len(l)#defining e variable lengths of the file  

   s=m#defining s variable that holds parameter value

   if(m<1):#Using if block that checks m is less than 1

       s=1#use s variable that holds a value that is 1

   if(n < e):#defining n variable that checks n less than e

       e=n #using e that holds n value

   for i in range(s-1, e, 1):#defining for loop that calculates lines  

       print(l[i])#prints lines

readlinesmton("input.txt", -1, 70)#Calling a method

Output:

Please find the ouput in the attached file.

Explanation:

In this code, a method "readlinesmton" is declared that takes three-parameter and inside the method, it uses the open method to open the file, read method to read the file, and len to calculate the length of the file and use the conditional statement to check the file inputs and use the loop to prints its values.    

You might be interested in
Blockquote
docker41 [41]

Answer:

I don't knowthe answer

Explanation:

I really don't know the answer

3 0
2 years ago
Tcp takes a three-step approach to establishing a reliable communication. first, from the transport layer of the sending device
tiny-mole [99]

TCP takes a three-step approach to establishing a reliable communication.

First, from the transport layer of the sending device a request packet is transmitted to the receiving device's transport layer asking if a session can be established.

Second, if available, the receiving device sends a packet back to the sending device indicating that it is available for communication.

Third, the sending device begins to send its data to the receiving device.

4 0
2 years ago
If you face an investigation where dangerous substances might be around, you may need to obtain which of the following?
AveGali [126]

Answer:

HAZMAT certificate

Explanation:

If you face an investigation where dangerous substances might be around, you may need to obtain a HAZMAT certificate.

Hazmat is the shortened form of the word "hazardous materials," which the United State Department of Transportation recognized as materials that could adversely affect people and also the environment. Hazmat certification is required to be obtained by workers who remove, handle, or transport hazardous materials. This comprises careers in transportation and shipping, firefighting and emergency rescue, construction and mining, as well as waste treatment and disposal. Workers who are also in manufacturing and warehouse storage may also come across hazardous substance or materials risks while on their jobs. Certification involves having the knowledge of the risks and safety measures for handling these materials.

6 0
3 years ago
Read 2 more answers
What report provides data on how specific sections of a website performed?
zalisa [80]

Answer:What report provides data on how specific sections of a website performed? 100% Correct Answer: Content Drilldown report

Explanation: sorry if it’s wrong

3 0
2 years ago
Which of the following type of software application would open a txt file
kogti [31]
I think that it's A or C
3 0
2 years ago
Read 2 more answers
Other questions:
  • What is the name of the process of heat transfer in which heat is transmitted through light waves?
    7·2 answers
  • 1. Which sign-in method requires users to press Ctrl+Alt+Delete before signing in?
    5·1 answer
  • What conversion factor should be used to convert from meters to Gigameters?
    7·1 answer
  • If you do not specify any criteria in a delete query, Access will delete all the records in the table. Truth or False
    11·1 answer
  • What will be displayed if the following Java code segment is run? System.out.println("one "); System.out.print("two "); System.o
    12·1 answer
  • Write a program that asks the user to enter the size of a triangle (an integer from 1 to 50). Display the triangle by writing li
    14·1 answer
  • Define the terms of data and information .​
    6·1 answer
  • Name any four areas where computers are used​
    15·1 answer
  • Compare and contrast two fundamental security design principles in network security. Analyze how these principles and how they i
    15·1 answer
  • What do you call a collection of pre-programmed commands and functions used in programs?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!