Programming Exercise 5.2 Instructions 23 alı gº @ Write a program that allows the user to navigate the lines of text in

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Programming Exercise 5.2 Instructions 23 alı gº @ Write a program that allows the user to navigate the lines of text in

Post by answerhappygod »

Programming Exercise 5 2 Instructions 23 Ali Go Write A Program That Allows The User To Navigate The Lines Of Text In 1
Programming Exercise 5 2 Instructions 23 Ali Go Write A Program That Allows The User To Navigate The Lines Of Text In 1 (96.58 KiB) Viewed 18 times
Programming Exercise 5 2 Instructions 23 Ali Go Write A Program That Allows The User To Navigate The Lines Of Text In 2
Programming Exercise 5 2 Instructions 23 Ali Go Write A Program That Allows The User To Navigate The Lines Of Text In 2 (110.92 KiB) Viewed 18 times
Programming Exercise 5 2 Instructions 23 Ali Go Write A Program That Allows The User To Navigate The Lines Of Text In 3
Programming Exercise 5 2 Instructions 23 Ali Go Write A Program That Allows The User To Navigate The Lines Of Text In 3 (52.53 KiB) Viewed 18 times
Programming Exercise 5.2 Instructions 23 alı gº @ 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 O, the program quits. Otherwise, the program prints the line associated with that number. An example file and the program input and output is shown below: example.txt Line 1. Line 2. Line 3. Enter the input file name: example.txt The file has 3 lines. Enter a line number [0 to quit]: 2 2: Line 2. The file has 3 lines. Enter a line number [0 to quit]: 4 ERROR: line number must be less than 3. The file has 3 lines. Enter a line number [0 to quit]: 0 Make sure the program gracefully handles a user entering a line number that is too high. Grading When you have completed your program, click the Submit button to record VOUR

CENGAGE MINDTAP Programming Exercise 5.2 Tasks =10 The program works as expected for given input, test 1 || 6.67 out of 10.00 8 This test checks that the program gracefully handles a user entering a line number that exist in the text file and prints that line. Make sure your program gracefully handles a user entering a line number that exist in the file and prints that line. Checks Custom Test Complete Delete file at start Custom Test Complete Create test file 1 Test Case Incomplete Verify program with test file 1 Custom Test Complete Delete files at end 8.33 out of 10.00 The program works as expected for given input, test 2 This test checks that the program gracefully handles a user entering a line number greater than the total line numbers in the text file. Make sure your program gracefully handles a user entering a number that is too high. Checks Custom Test Complete Delete file at start > > example.txt navigate.py + 1 enterfile= input("example.txt: ") 2 file = open(enterfile, 'r') 3 linecount = 0 4 5 for line in file: 6 7 8 print("The number of lines in this txt. file is", linecount) 9 10 while True: 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 linecount linecount + 1 linenum = 0 num= int(input("Please enter a line number or press to quit: ")) if num >=1 and num <=linecount: file = open(enterfile, 'r') for lines in file: linenum else: if linenum == num: print (lines) if num ==0: linenum 1 print("Thanks for using the program") break

8.33 out of 10.00 The program works as expected for given input, test 2 This test checks that the program gracefully handles a user entering a line number greater than the total line numbers in the text file. Make sure your program gracefully handles a user entering a number that is too high. Checks Custom Test Complete Delete file at start Custom Test Complete Create test file 2 Test Case Incomplete Verify program with test file 2 Complete Custom Test Delete files at end
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply