Capture and paste two program code segments you developed during the administration of this task that contain a list (or other collection type) being used to manage complexity in your program.
i. The first program code segment must show how data have been stored in the list.
ii. The second program code segment must show the data in the same list being used, such as creating new data from the existing data or accessing multiple elements in the list, as part of fulfilling the program’s purpose.
Then, provide a written response that does all three of the following:
iii. Identifies the name of the list being used in this response
iv. Describes what the data contained in the list represent in your program
v. Explains how the selected list manages complexity in your program code by explaining why your program code could not be written, or how it would be written differently, if you did not use the list
First code segment:
Second code segment:
The code uses the list word. The list stores the two words that are used by the program. The first entry in the list is the unencrypted word and the second entry is the encrypted word.
The list helps manage complexity because it allows both the un-encrypted word and the encrypted word to be stored in a single variable that is accessible in both the main program to print the results and the function to encrypt the word. If the program did not use a list, it would be more complicated because the values would have to be passed back and forth with the function.
The two test cases are based on different shift amounts that are input for the same word. In the first case, Hello was entered and the shift was 5. For this test case, the encrypt function will take each letter and shift it over by 5 places. The result from this was MJQQT. The second call used the word Hello again, but this time shifted the letter 20 places. By shifting the letters 20 places, it causes the letters to wrap around and the results is BYFFI.
The response earned the point for this row, meeting all six criteria:
• The video demonstrates the program receiving user input for both the unencrypted phrase and the shift
• The program's purpose is to encrypt a phrase and the video demonstrates this purpose
• The program demonstrates output by printing out the encrypted phrase
• The input and output is described in the response by stating "In the video, you can see 2 different inputs. The first input is the un-encrypted phrase and the second input is the number of characters to shift the letters. You can also see the program output the encrypted phrase."
The response earned the point for this row, meeting all three criteria:
• Two distinct code segments are shown
• The name of the list is described as word
• The response states what values are stored in the list and how it serves the function of the program here: "it allows both the un-encrypted word and the encrypted word to be stored in a single variable that is accessible in both the main program to print the results and the function to encrypt the word."
The response does not earn the point for this row. Even though the program states how it manages complexity and how it would be different without a list, the use of a list in this scenarios does not actually make the program less complex.
• The response includes a program code segment that shows a list being used; however, the list does not manage complexity in the program, as the same result could be accomplished with two variables.
• Using two variables and/or passing values back and forth between the main program and the function would not make the program any more complex than it currently is.
The response earned the point for this row, meeting both criteria:
• The response includes two distinct code segments, one defining a function encrypt with the key parameter and the other calling this function
• The response describes how the procedure contributes to the program functionality by stating "This contributes to the overall program execution by performing the encryption on a given word and then storing that word in the word list so that the main program can print out the decrypted word."
The response does not earn the point for this row. The selected algorithm includes sequencing, selection, and iteration, however the response does not state how the selection statement is being used. While the code is sufficient to earn the point, the point is not earned because the explanation was not thorough enough.
The response does not earn the point for this row as it does not meet the first requirement:
• Two different calls are described, 5 and 20. For each, the code segment that is executed is described, however the same set of code is run in each case. To earn the point, one of the test needs to run the else cause of the selection statement.
• For each call, the condition being tested is described. "By shifting the letters 20 places, it causes the letters to wrap around..."
• The result of each call is described in the response.