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
Need help on this it’s the last one I need
BaLLatris [955]
Design a ringtone like it says
8 0
3 years ago
What is an implicit benefit to Monetary Policy?
Mariana [72]
The answer to your question is a
6 0
3 years ago
Which of the following tools enables users to connect to a remote computer, including servers with no interaction required from
lana66690 [7]

Answer:

Remote Desktop

Explanation:

This is a software, that enable you to connect with a remote computer with all access. e.g. Team Viewer

3 0
3 years ago
In Super Mario 64, a character called Lakitu follows Mario around on a cloud, filming him with a camera as though he were shooti
ella [17]

Answer:

A second person prespective

Explanation:

6 0
3 years ago
Read 2 more answers
How do you think calculator of a computer works? describe the procedure.
Leviafan [203]

Explanation:

calculators work by processing information in binary form. We're used to thinking of numbers in our normal base-ten system, in which there are ten digits to work with: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. The binary number system is a base-two system, which means there are only two digits to work with: 0 and 1. Thus, when you input numbers into a calculator, the integrated circuit converts those numbers to binary strings of 0s and 1s.

The integrated circuits then use those strings of 0s and 1s to turn transistors on and off with electricity to perform the desired calculations. Since there are only two options in a binary system (0 or 1), these can easily be represented by turning transistors on and off, since on and off easily represent the binary option

Once a calculation has been completed, the answer in binary form is then converted back to our normal base-ten system and displayed on the calculator's display screen.

8 0
3 years ago
Other questions:
  • In the space below, write the formula that needs to be added to the blank cells under the fourth column of the table.
    13·1 answer
  • Which tool allows multiple users to dynamically update a document at the same time? Question 3 options: Google Docs OneDrive Exc
    14·1 answer
  • Please check my answer! (Java)
    13·1 answer
  • C++ CODE
    6·1 answer
  • Suppose that outfile is an ofstream variable and output is to be stored in the file outputData.out. Which of the following state
    15·1 answer
  • Consider the following statement from the CS Principles course framework: The global distribution of computing resources raises
    12·1 answer
  • Which of the following is a hand-drawn animation that takes a large amount of time to complete?
    5·1 answer
  • ......... mi2hej<br><br>ejid8eo19o1b2bxhxjxjdnneejk2929nr
    5·2 answers
  • PLEASE ANSWER THIS ASAP‼️
    10·2 answers
  • What does the word collaborative mean?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!