You are on page 1of 2

7/13/2021 Please Use Python Programming 3.6. Write A Program... | Chegg.

com

  Textbook Solutions Expert Q&A Study Pack Practice 

Find solutions for your homework Search

home / study / engineering / computer science / computer science questions and answers / please use python programming 3.6. write a program …

Question: Please use python programming 3.6. 


Write a program that all… Post a question
Answers from our experts for your tough
homework questions
(3 bookmarks)

Please use python programming 3.6. Enter question


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
Continue to post
associated with that
number.
19 questions remaining
An example file and the program input and output is shown
below:
example.txt
Line 1.

Line 2.
Snap a photo from your
Line 3.
phone to post a question
Enter the input file name: example.txt
We'll send you a one-time download
link
The file has 3 lines.

Enter a line number [0 to quit]: 2

2 : Line 2. 888-888-8888 Text me


The file has 3 lines.

Enter a line number [0 to quit]: 0


By providing your phone number, you agree to receive a one-tim
automated text message with a link to get the app. Standard
messaging rates may apply.

Expert Answer

Anonymous answered this


My Textbook Solutions
Was this answer helpful? 7 0
72,223 answers

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

f = open(filename, 'r')

lines = f.readlines()

f.close()

Fundament... Fundament... Principles of..


print()

while True:
2nd Edition 1st Edition 9th Edition
print("The file has {} lines.".format(len(lines)))

View all solutions


n = int(input('Enter a line number [0 to quit]: '))

if n == 0:

break

print("{} : {}".format(n, lines[n - 1].strip()))

Comment


Practice with similar questions

Q: 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...

A: See answer

Q: 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...

A: See answer 100% (5 ratings)

Show more 

https://www.chegg.com/homework-help/questions-and-answers/please-use-python-programming-36-write-program-allows-user-navigate-lines-text-file-… 1/2
7/13/2021 Please Use Python Programming 3.6. Write A Program... | Chegg.com

Up next for you in Computer Science


  Textbook Solutions Expert Q&A Study Pack Practice 

In Python Please. In May i please have

Chapter
pseudocode and testcase

4, we developed an
making sure there are no

algorithm for converting bugs please for the


from
following
See more questions
binary to decimal. You code(java): //
for subjects you study
can
WebSiteGenerator.java

generalize this algorithm import java.io.*; import

See answer See answer

Questions viewed by other students

Q: Write a python program that allows the user to navigate the


lines of text in a file. The program should promt 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...

A: See answer

Q: 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...

A: See answer

Show more 

COMPANY

LEGAL & POLICIES

CHEGG PRODUCTS AND SERVICES

CHEGG NETWORK

CUSTOMER SERVICE

© 2003-2021 Chegg Inc. All rights reserved.

https://www.chegg.com/homework-help/questions-and-answers/please-use-python-programming-36-write-program-allows-user-navigate-lines-text-file-… 2/2

You might also like