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
Methods that require you to use an object to call them are called ____ methods.1. accessor2. instance3. internal4. static
spin [16.1K]

Answer:

Option 2 i.e., instance methods is the correct answer to the following question.

Explanation:

Because the instance method or function is the function that needed the class object to be called.

<u>For Example:</u>

//header file

#include <iostream>

using namespace std;

//define class

class Test

{

public:

//instance method

void getins()

{  

cout<<"I AM Instance method";

}

};

int main()

{

//creating object

Test obj;

//calling of instance method through class object

obj.getins();

}

<u>Output</u>:

I AM Instance method

3 0
3 years ago
In which view of PowerPoint is the Annotation tools menu available?
lara31 [8.8K]

Answer:

2.

Explanation:

Annotating in PowerPoint is the create notes while delivering a PowerPoint presentation. This could be done in two ways.

First, right click with the mouse and select 'pointer options'. Then you can choose either pen or highlighter to circle certain word or highlight any line.

The second way of creating annotation is by going to View→Normal→Notes.

After you select 'notes', a pane will appear at the bottom of your presentation.

So, the correct answer that annotation tools menu is available in Normal. Thus option 2 is correct.

7 0
2 years ago
Read 2 more answers
How many words fit on a double-spaced page?
sveticcg [70]
It depends on the length of the words.
5 0
3 years ago
Can anyone give me nitrotype gold? Name username is lol3628 display name is iluvkitkats
Vsevolod [243]

Answer:

no

Explanation:

3 0
3 years ago
Read 2 more answers
Class 7th Subject Computer all chapters 2nd page​
LenKa [72]

no.13 answer is( B ) and no.14 answer is also (B)

7 0
3 years ago
Other questions:
  • Which tool encrypts entire drives, rendering them unusable unless one possesses the correct key to unlock the drive?
    8·1 answer
  • You're the network administrator for a company that has just expanded from one floor to two floors of a large building, and the
    7·1 answer
  • Does anyone know? If you do please answer.
    9·1 answer
  • im in honors comupter science and one of my questions is evaluate 18% 7 does anyone know how to answer that
    6·1 answer
  • The minimum spanning tree of an undirected graph G exists if and only if G is connected. True or False?
    12·1 answer
  • Why When I change my pfp It be blurry and it be ugly- if you know what I mean :c
    15·2 answers
  • Defination of formula work sheet​
    15·1 answer
  • Why should we not underestimate the widespread of mass media?
    13·1 answer
  • Definition of Computer forensics?
    12·2 answers
  • When one loop appears inside another, the loop that contains the other loop is called the ____ loop. Group of answer choices ind
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!