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
What your favorite video game? (Put your user if you wanna play!)
Dvinal [7]

Answer:

TRAILMAKERS PS4 but will be PS5 when comes out

Explanation:

my user is Tow4cardinals

6 0
3 years ago
Read 2 more answers
an engineer is writing a web application that requires some user input. the engineer has put a submit button on their page and n
Setler [38]

In order to make the program recognize the clicking of a button, the engineer should add an event listener to the JavaScript code.

An event is considered to be a vital part of JavaScript because a web page responds according to the event that occurred. Some events are generated by APIs and some are user-generated events. For example, clicking or moving the mouse button and pressing a key on the keyboard are user generated events.

In order to handle the user-generated events in JavaScript,  an event listener is used. An event listener is a function or procedure in a JavaScript program that waits for an event to occur; such as pressing a key on the keyboard or clicking the button. Therefore based on the scenario given in the question statement, the engineer should use an event listener to his JavaScript code so that the code can recognize the click of the button.

You can learnmore about event at

brainly.com/question/20169706

#SPJ4

7 0
1 year ago
Ew<br>subject: Computer<br>11101÷101<br> binary operations<br>​
lions [1.4K]
11101 / 101 = 109.9
5 0
3 years ago
A software program that includes tools for entering, editing, and formatting text and graphics is called a word processing progr
shtirl [24]

i think the answer is true

7 0
3 years ago
It converts Assembly Language into machine language?​
docker41 [41]

Answer:

An assembler.

Explanation:

Input is (as with any programming language) files with lists of instructions (typically assembler mnemonics), output is a binary format representing these instructions in machine language.

6 0
2 years ago
Other questions:
  • Which Game Is Better &amp; Favorite For You?
    12·2 answers
  • Write a function called lucky_sevens that takes in one #parameter, a string variable named a_string. Your function #should retur
    15·1 answer
  • In presentation software, what is the way that text and pictures are arranged on a page called?
    10·1 answer
  • When it comes to the best possible security for your wireless router, be sure to use WEP encryption to ensure that your transmis
    14·1 answer
  • If you're unsure of what chart to use for a set of data, what feature does Excel include that will help you to decide?
    7·1 answer
  • A TCP ________ segment is a request to the other transport process to close a connection. ACK FIN SYN CLS
    15·1 answer
  • 1. Write a program to input four numbers and store them in variables.
    6·1 answer
  • Who can add entries to value log
    8·1 answer
  • Universal containers set the organization-wide defaults for cases to private. When a case is escalated, case ownership changes t
    13·1 answer
  • What type of error occurred with the code below??
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!