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
Suppose one hundred stores participated in the
Sindrei [870]
I think the answer is A
7 0
3 years ago
What is bug in computer?​
Anton [14]

Answer:

<h2>A bug in a computer is refered to as a "computer virus" its where certain things on the computer or apps on it aren't working like they were designed to. </h2>

Explanation:

<h2>Hope this helps:)!</h2>
6 0
3 years ago
A line beginning with a # will be transmitted to the programmer’s social media feed.
zhenek [66]

Answer:

True?

Explanation:

4 0
3 years ago
Read 2 more answers
Is permanent software programmed into read-only memory.<br> Firmware<br> JavaScript<br> PHP<br> o
velikii [3]
Firmware is the software
5 0
3 years ago
Why does angular page look different after refresh.
alukav5142 [94]
Most of the web applications are written with SPA frameworks such as Angular, React, Vue.js, etc. The problem with these SPAs is that the single page is loaded in the browser once and then the framework will take care of all the routing among pages and gives the impression to the user that it is a multi-page application. When you refresh your page in the browser that single page called index.html is reloaded and you will lose the entire state of the application.
3 0
3 years ago
Other questions:
  • Two or more computers that transfer information between computers are called a
    7·1 answer
  • A network administrator is implementing dhcpv6 for the company. the administrator configures a router to send ra messages with m
    6·1 answer
  • A slightly tapered thread is characteristic of a _______ tap.
    15·1 answer
  • c++ design a class named myinteger which models integers. interesting properties of the value can be determined. include these m
    14·1 answer
  • Suppose a retailer who has no technology expertise wishes to set up an online presence for his business. He ________. a. ​can us
    6·1 answer
  • An enterprise system is a packaged software application that helps integrate various ___________ in a company.
    15·2 answers
  • Is there a way to earn free robux
    7·2 answers
  • Questions Presscomion
    9·1 answer
  • Hi um... i just wanna say hi :P
    6·2 answers
  • Explain why you do not need expensive equipment to take pictures or record video?
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!