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
ArbitrLikvidat [17]
3 years ago
7

Write a program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename

and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the program quits. Otherwise, the program prints the line associated with that number.
It should be like as this sample run follows.

Enter the input file name: quotes.xtxt
I cannot open the file quotes.xtxt - Please check the name and try again.
Enter the input file name: quotes.txt
The file has 16 lines.
Enter a line number [0 to quit]: 1
1: Hakuna Matata!
Enter a line number [0 to quit]: -1
Try again. Line number must be between 0 and 16
Enter a line number [0 to quit]: 16
16: Just keep swimming!
Enter a line number [0 to quit]: 17
Try again. Line number must be between 0 and 16
Enter a line number [0 to quit]: 5
5: It's kind of fun to do the impossible.
Enter a line number [0 to quit]: A
Try again. Please enter a number between 0 and 16
Enter a line number [0 to quit]: $
Try again. Please enter a number between 0 and 16
Enter a line number [0 to quit]: 4
4: To infinity and beyond!
Enter a line number [0 to quit]: 0
Computers and Technology
1 answer:
pickupchik [31]3 years ago
7 0

Answer:

Explanation:

iname=input("Enter the file name: ")

inputfile=open(iname,'r')

lines=[]

for line in inputfile:

lines.append(line)

inputfile.close()

print("The file has ",len(lines)," lines")

while True:

linenumber=int(input("Enter the line number or 0 to quit: "))

if linenumber==0:

break

elif linenumber > len(lines):

print("Error: line number must be less than ", len(lines))

else:

print(linenumber, " : ", lines[linenumber - 1])

You might be interested in
Computers process information consistently for all transactions. This creates a risk that:______
Anna007 [38]

Answer:

b. erroneous processing can result in the accumulation of a great number of misstatements in a short period of time.

Explanation:

Because of the consistent nature of processing in computers, this is capable of creating certain kinds of risk. From the option, one of the probable risk that can result from consistent information processing for multiple transactions at the same time is erroneous processing. This can therefore lead to a pile of misstatements in only a short period of time.

6 0
3 years ago
What can be can be considered data
gavmur [86]

Answer:

The amount of data you use while talking on a phone is a form of data.

Explanation:

8 0
3 years ago
You are preparing to give a presentation at a client’s location using your mobile device and a large screen TV. You have success
Ray Of Light [21]

Answer:

The most probable reason for this is A.

Explanation:

B should be wrong because the TV being connected to a different network segment still means that it is on the Wi-Fi network, it is just using a different switch or a repeater.

C should be wrong because the brightness of the TV does not have anything to do with being able to connect to the phone.

D should be wrong because in the question itself it says that "you tap the mirroring option on your device" which clearly means that the mobile device supports display mirroring.

The answer should be A, if the device and the TV are not on the same Wi-Fi network, than they simply can not connect and the mirroring can not be done.

I hope this answer helps.

7 0
3 years ago
Say anything :) teeheeheheheheehhehe
nataly862011 [7]

Answer:

905 shooter slidin on the block he shot at opps no he got can stop running from the cops...

Explanation:

ON GANG PRRRA...

3 0
3 years ago
Read 2 more answers
Which of these characteristics is most important to a systems analyst? (1 point) (Points : 1.5) communicator
zvonat [6]

Answer: Problem solver

Explanation:

 Problem solver is the most important characteristics for the system analyst as it important for the organization to control all the problems.

System analysis basically define the problem in the particular organization to be solved and also provide the proper architecture in the system.  

The good and strong problem solving ability makes the organization more efficient in the decision making problem and also improve the overall system analyst in the organization.

7 0
3 years ago
Other questions:
  • Carmina wants to move a paragraph to the right margin of the document she is working in. She moves her cursor to
    8·2 answers
  • How do u change the level of education on Brainly. cuz i just finished elementry
    9·2 answers
  • Summarize the five stages of cultural shock
    11·2 answers
  • Cameron oversees inventory tracking in her school store. Which feature in a database allows her to organize the items from highe
    6·1 answer
  • How would you classify an employee who is punctual, has respect for oneself and others, and takes initiative?
    13·2 answers
  • When does information become a liability for an organization
    6·1 answer
  • When comparing different biometric systems, one of the most important metrics used is called the _________, which represents the
    14·1 answer
  • Project 15A - Math Application
    10·1 answer
  • What are the five generations of computer software​
    13·1 answer
  • Write a question that the database will understand. Which records do not contain "sold"?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!