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
The cost of a CLEP exam is about__<br><br> A$100 <br> B $50 <br> C$80<br> D$170
Elanso [62]

Your answer is C or $80

When averaging the costs of credit hours at public and private community colleges and four-year institutions, the median cost for a three-hour class in 2017 was $1,782. Conversely, each CLEP exam costs $85.

5 0
3 years ago
Read 2 more answers
chapter tests and exams are password protected and must be taken in the lab with a universal kiosk browser
Nesterboy [21]

Yes, when a universal kiosk browser (chrome books) being used in the lab during test and exams is protected by avoiding the students to check the answers in the online.

Explanation:

Universal kiosk browser is helpful to display the content on the web on Chrome books. Chrome books are being safe to make student assessment processes. With the help of this, accessing websites to find the answer to the questions in the assessment process by the student is being avoided.

4 0
2 years ago
When you pass an array name as an argument to the function what is actually being passed
Allushta [10]

Answer:

The Base address of the array is being passed

6 0
3 years ago
A mismatch between the type of printer connected to a system and the software printer driver installed is an example of a ____.
mixer [17]
ERROR! It is an example of an error
6 0
3 years ago
When you get a new sim card do it come with a new number or do you have a activate the phone and get a new number in store ?
Paul [167]

put the sim card in the phone and turn the phone on, it technically comes with the card but you really interact with it until you turn the phone on.

5 0
2 years ago
Other questions:
  • Using Turtle Graphics, write a program that will produce 2 Zs next to each other. It is irrelevant where these Zs appear and wha
    10·1 answer
  • How do you return a value from a function?
    6·1 answer
  • What is the difference between a Network Diagram and a Wiring Semantic?
    5·1 answer
  • Identify the careers that require a college degree
    9·1 answer
  • Which branch of science helps avoid or minimize stress-related injuries at workplace?
    14·2 answers
  • Which line of code will eliminate the element “calculator” from an array of supplies?
    13·1 answer
  • How do you make a ringtone on earsketch
    9·1 answer
  • If the three operations were combined, O(logN) + O(N) * O(logN) + 1, the overall algorithm cost would be:________
    6·1 answer
  • The History feature of a browser enables you to retrace your browsing history over a short period of time. (1 point) True False
    9·1 answer
  • Consider sending a stream of packets from host a to host b using ipsec. typically, a new sa will be established for each packet
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!