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
erastovalidia [21]
2 years ago
6

Write a program that asks the user for the name of a text file. The program should display the first 10 lines of the file on the

screen. If the file has fewer than 10 lines, the entire file should be displayed along with a message indicating the entire file has been displayed.
Computers and Technology
1 answer:
tangare [24]2 years ago
5 0

Answer:

Written in Python

filenm = input("File name: ")

myfile = open(filenm+".txt")

for i in range(10):

     line = myfile.readline()

     print(line)

print("End of file")

Explanation:

This line prompts user for file name

filenm = input("File name: ")

This line creates an instance of the file

myfile = open(filenm+".txt")

This line iterates through the 10 lines

for i in range(10):

This line reads the line

     line = myfile.readline()

This line prints each line

     print(line)

This line prints a message indicating that all possible lines have been printed

print("End of file")

You might be interested in
When using a wireless mouse, what is the most common port used for the transmitter? 
larisa [96]
Your answer is B. USB
7 0
3 years ago
A web page ____ can also create a style sheet that takes precedence over the internal style sheets of browsers.
posledela
This work can be done only by the creator of that web page. So i can recommend it will be 
creator / author
5 0
3 years ago
How was science used to make television?
Wewaii [24]

Answer:

Sir William Crookes invented the cathode ray tube in 1878, but these discoveries took many years to merge into the common ground of television. His mechanical system used a scanning disk with small holes to pick up image fragments and imprint them on a light-sensitive selenium tube. A receiver reassembled the picture.

5 0
3 years ago
Read 2 more answers
Where can you access email accounts on your windows 7 computer in order to modify current accounts or create new ones?
Mademuasel [1]
I'll create new ones because just for me, its so hassle
8 0
3 years ago
Which is an example of an binary number?
Liula [17]
The second one
01111
This is because a computer uses binary and only understands two digits which consit of 1 and 0
8 0
3 years ago
Read 2 more answers
Other questions:
  • What is tuple and attribute of a relation​
    11·1 answer
  • Maria is comparing her history project's second-place award to her classmate's first-place award. She starts planning how to win
    6·2 answers
  • Examples of algorithm
    5·1 answer
  • "where is a cookie that is created during a web site visit​ stored?"
    9·1 answer
  • You’re responding to a troubleshooting ticket about a laser printer in HR that isn’t working. According to reports, the printer
    7·1 answer
  • The picture that graphically represents the items you use in windows is called a/an
    5·1 answer
  • Which of the following is not hardware? wireless network router X-box 360 game controller virus scanner flat-panel monitor
    5·2 answers
  • This is for career exploration, I need help please! <3 HELPPPP
    8·2 answers
  • ¡Hola! He visto en muchos comentarios de Twitter "svd" cuando alguien dice "dale fav a este Tweet y siganse entre ustedes" y en
    8·1 answer
  • WHO WANT P O I N T S.................................................
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!