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
dezoksy [38]
3 years ago
8

Write a program that Read first n lines of file

Computers and Technology
1 answer:
sergejj [24]3 years ago
7 0

Answer:

Python 2:

with open("datafile") as myfile:

   head = [next(myfile) for x in xrange(N)]

print head

Python 3:

with open("datafile") as myfile:

   head = [next(myfile) for x in range(N)]

print(head)

Both Python 2 & 3:

from itertools import islice

with open("datafile") as myfile:

   head = list(islice(myfile, N))

print head

You might be interested in
The Nigerian 4-6-9 scam refers to a fraudulent activity whereby individuals claiming to be from a foreign country will promise a
Serhud [2]

Answer:

<em>b. False</em>

<em></em>

Explanation:

<em>The system of fraud is called 4-1-9 scam</em>. And yes, victims are always promised large sum of money to secretly help in moving a large sum of money.

7 0
3 years ago
Clicking on this will minimize all open windows.
vfiekz [6]
I believe it is the the Show Desktop Icon.
Hope this helps! <3
4 0
3 years ago
Read 2 more answers
Every workplace should have an emergency plan of action.
pochemuha

Answer:

yes i agree with that the answer is in fact true

Explanation:

follow my in sta gram at grac.ehihi

6 0
3 years ago
Read 2 more answers
Mary needs to choose the menu in order to place the text in a desired fashion around the image.
n200080 [17]
Can you be more specific?

7 0
4 years ago
Read 2 more answers
Where is the fill handle located
Ronch [10]
The fill handle will appear as a small square in the bottom-right corner of the selected cell(s). Click, hold, and drag the fill handle until all of the cells you want to fill are selected. Release the mouse to fill the selected cells
4 0
3 years ago
Other questions:
  • A technology company only hires applicants who are under the age of 30. This company could face possibly _________ consequences
    9·2 answers
  • Name a computer programme that designers are likely to use to create a leaflet advertising their new product
    15·1 answer
  • Which of the following is a reason why the comments tool within PDF documents could be helpful? (Select all that apply.)
    5·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    11·1 answer
  • Which is a characteristic of an effective problem statement? It is based on research. It contains outside information. It contai
    12·1 answer
  • Is there truth? Does truth exists?
    14·2 answers
  • Which of the following is a strategy used to enhance communication in a presentation?
    14·1 answer
  • You are given an integer N, followed by N lines of input (1 &lt;= N &lt;= 100). Each line of input contains one or several words
    8·1 answer
  • Write a program that performs the following tasks: Display a friendly greeting to the user Prompt the user for the value to conv
    13·1 answer
  • PLEASE HELP!! WILL MARK BRAINLIEST!!
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!