Question: QUESTION 1 Consider a non-empty Python list variable called names which contains strings Below is incomplete code which is intended to print the length of








QUESTION 1 Consider a non-empty Python list variable called names which contains strings Below is incomplete code which is intended to print the length of the longest string in the list names. The code is supposed to work by scanning across the list, using the variable best to keep track of the longest name seen so far Three ways to do this are: (1) remember the name using the variable best; (2) ember the name's position in the list using the variable best; or (3) ember the length of the name using the variable best. Each box contains a number of optional labelled lines of code which would be used for the implementations above. They are not in any particular order YOUR TASK is to first make a choice about which implementation you will use (it does not matter which). Then determine which combination of lines of code will cause the code to print the length of the longest string in the list names Either: (a) 0 (b) names [0] best - or for index in range (len (names)) Either: (a) len (best) (b) len (names [best]) (c) best if len (names [index]) > or or Either: or: or: (a) names [index] (b) index (c) len (names [index]) best- Either: (a) len (names [best]) (b) n (best) (c best print( or: or
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
