Sign In
Ask Question
Harley Meyer
Computers & Technology
9 May, 19:32
Write a program that Read first n lines of file
+5
Answers (
1
)
Kate Lester
9 May, 19:51
0
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
Comment
Complaint
Link
Know the Answer?
Answer
Not Sure About the Answer?
Find an answer to your question 👍
“Write a program that Read first n lines of file ...”
in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers
You Might be Interested in
Unwanted web pages that appear automatically while you are attempting to browse something else are called
Answers (1)
Most of the international operations in a computer use hexadecimal numbering. True Or False
Answers (1)
What is the most common way for computing systems and devices to authenticate a person's identity? citi
Answers (1)
Write a complete program that declares an integer variable, reads a value from the keyboard into that variable, and writes to standard output the variable's value, twice the value, and the square of the value, separated by spaces.
Answers (1)
Before you touch a wire in an appliance, how should you make sure that it is not energized?
Answers (2)
New Questions in Computers & Technology
You work for a computer reseller. A customer walks in and asks you what the main differences are between a Mac and a PC. You tell her that there are slight differences in the look and feel.
Answers (1)
What information does a Transform hold? (Choose all that apply) Scale Position Rotation Velocity
Answers (1)
A structure is private by default, but can be declared to be friend or private.
Answers (1)
Incomplete Configuration identification documents may resultin: a) Defective Product b) Higher Maintenance Costs c) Schedule Product d) Meet Software Quality e) A, B, C f) B, C, D
Answers (1)
Why would a person who handles electronic components wear a grounded wrist strap
Answers (1)
Home
»
Computers & Technology
» Write a program that Read first n lines of file
Sign In
Sign Up
Forgot Password?