Programming Exercise 5.2 Instructions 23 alı gº @ Write a program that allows the user to navigate the lines of text in
-
- 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
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