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 is the significant feature of computer capabilities?​
Pepsi [2]
<h2>Hey mate </h2><h2>Here is ur answer..! ⬇️⬇️</h2>

Explanation:

<u>The characteristics of computers that have made them so powerful and universally useful are speed, accuracy, diligence, versatility and storage capacity. Let us discuss them briefly. Computers work at an incredible speed.</u>

<em><u>Hope</u></em><em><u> </u></em><em><u>it helps</u></em><em><u> </u></em><em><u>u plzz</u></em><em><u> </u></em><em><u>mark it</u></em><em><u> </u></em><em><u>as brainalist</u></em><em><u> </u></em><em><u>and thnk</u></em><em><u> </u></em><em><u>my answers</u></em><em><u> </u></em>

4 0
3 years ago
Explain the principles of computer applications ​
9966 [12]

Answer:

The nature of computers and code, what they can and cannot do.

How computer hardware works: chips, cpu, memory, disk.

Necessary jargon: bits, bytes, megabytes, gigabytes.

How software works: what is a program, what is "running"

How digital images work.

Computer code: loops and logic.

Big ideas: abstraction, logic, bugs.

3 0
2 years ago
Which of the following is true about science and technology?
kow [346]

Answer:

A

Explanation:

6 0
2 years ago
Suppose we want to compress a text consisting of 6 characters,a, b, c, d, e, fusingthe Huffman Algorithm. Give an example for wh
denis-greek [22]

Answer:

Check the explanation

Explanation:

When it comes to the field of computer science and information theory, the Huffman code is a specific type of optimal prefix code that is mostly utilized for the compression of lossless data. The process and procedures of finding or using such a code proceeds by means of Huffman coding, which is an algorithm that was developed by David A.

kindly check the below image for the complete answer to your question.

8 0
3 years ago
If someone were unable to pay cash right now, which financing option would be best for the laptop and for the refrigerator?
nadezda [96]

Answer

Installment

Explanation

Installment method of payment is where the customer who is the buyer agrees with the seller, that the buyer is issued with an item and pays at intervals. So the best  payment mode for the person who is not able to pay a laptop and for a refrigerator is by installment. And by the end of the agreed period and the person having able to pay the amount by the given time and the item will be his/her.

4 0
3 years ago
Read 2 more answers
Other questions:
  • Convert the following decimal number to its equivalent binary ,octal,hexadecimal 1920​
    12·1 answer
  • The term ________ refers to the use of a single unifying device that handles media, internet, entertainment, and telephone needs
    13·1 answer
  • Your company is instituting a new security awareness program. You are responsible for educating end users on a variety of threat
    10·1 answer
  • Does anyone know the answers to the AR test on Gathering Blue by Lois Lowery?
    10·1 answer
  • Which ofthe following sentence beginnings would be best to use in apersuasive request?
    8·1 answer
  • Demographics refers to
    7·1 answer
  • Character positions in<br> arrays start counting with<br> the number 1.<br> True<br> False
    14·1 answer
  • The following code is intended to test whether the int variable num is less than 10, and if so print a warning and set it to 10.
    6·1 answer
  • Pls someone help me with these four questions
    8·1 answer
  • Create a set of functions that compute the mean, median, and mode of a set of
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!