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
Create a flowchart to print numbers from 1 to 100
Mkey [24]

Answer:

brainliest plsss

Explanation:

I think so this is what you had asked!!!!!!

hope it helps

4 0
3 years ago
2.1 Changes in which factors could cause aggregate demand to shift from AD to AD1? What could happen to the unemployment rate? W
katrin [286]

Answer:

There are many factors that cause aggregate demand to shift from AD to AD1. The unemployment rate will fall and inflation will increase.

<u>Explanation:</u>

A Shift in aggregate demand from AD to AD1 means there has been a  fall in demand. Various factors that cause demand to decrease are:

  1. Increase in price of a good itself
  2. Increase in the price of complimentary goods-This will lead to a fall in demand. Like ink and pen are complementary goods. if the Price of ink increases then demand for pen will decrease.
  3. A Decrease in the price of substitute goods-Like tea and coffee.
  4. Expectation regarding future fall in price

So due to the decrease in demand finally the unemployment will increase and with that, the inflation rate will increase making  things dearer.

3 0
4 years ago
Try drawing the bass clef sign by tracing over the dotted lines. then draw five more on your own
Jobisdone [24]

Answer:

ok

Explanation:

did it. It was a little difficult to keep my pencil straight.

6 0
3 years ago
Design a 4-bit register that can accept an input from the user and store the accepted input. The 4-bit register will operate in
Digiron [165]

The answer & explanation for this question is given in the attachment below.

4 0
4 years ago
What is the purpose of the Revisions pane in a presentation?
lana [24]
First option


Sorry if I’m wrong
7 0
3 years ago
Read 2 more answers
Other questions:
  • Write a program that takes as input an arithmetic expression followed by a semicolon ";". The program outputs whether the expres
    11·1 answer
  • What are the two components that make up the chipset?
    15·1 answer
  • What can be done to improve the security of business uses of the Internet? Give several examples of ecurity measures and technol
    9·1 answer
  • The Springfork Amateur Golf Club has a tournament every weekend. The club president
    7·1 answer
  • Write a program that will take a user-input number and then display all of the whole # factors for that number. For example, if
    13·1 answer
  • Jade has to present a paper on the basic architecture of the Princeton microcomputer architecture model. Which option will he hi
    5·1 answer
  • Need the answer ASAP!!! I’ll mark brainliest if correct
    12·2 answers
  • Consider that a man is watching a picture of a Black Horse. He receives an external stimulus from input channel. Man gains some
    14·1 answer
  • PLEASE HELP!! THIS IS DUE SOON.
    13·1 answer
  • A(n) Blank______ database model stores data in the form of logically related two-dimensional tables. Multiple choice question. w
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!