Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PYTHON LANGUAGE: Write test cases to test the following program for accuracy, us

ID: 3574341 • Letter: P

Question

PYTHON LANGUAGE:

Write test cases to test the following program for accuracy, using a white-box testing method. The program is intended to display a menu and ask the user to enter commands from the keyboard.

continYu= True

while continYu == True:

print('Choose an option below:')

print('e: enter a list of words')

print('p: print all the words in your list')

print('c: remove the first word from your list')

print('l: print the longest word in your list')

print('q: quit')

choice = input('')

if choice == 'e':

l = input("Your list: ")

elif choice == 'p':

print(l.split())

elif choice == 'c':

words= l.split()

words.pop(0)

print(words)

elif choice == 'l':

print('later')

elif choice =='q':

break

else:

   print('make another choice')

print('Thanks')

Explanation / Answer

while True:
   print('Choose an option below:')
   print('e: enter a list of words')
   print('p: print all the words in your list')
   print('c: remove the first word from your list')
   print('l: print the longest word in your list')
   print('q: quit')
   choice = input('Make a choice:')
   print(choice)
   if choice == 'e':
       l = input("Your list: ")
       l = l.split()
       print("The current items in the list is ",l);
   elif choice == 'p':
       print(l)
   elif choice == 'c':
       l = l[1:]
       print(l)
   elif choice == 'l':
       if(len(l)==0):
           print("No words in the list!")
           continue
       mx = 0
       for kk in range(1,len(l)):
           tmp = len(l[kk])
           if(tmp>len(l[mx])):
               print("The word "+l[kk]+" is greater than "+l[mx])
               mx = kk
       print("The longest word is "+l[mx])
   elif choice =='q':
       break
   else:
       print('Make another choice:')
print('Thanks')