Menu

Q6 Indexing 05 Points Using Four Lists Provided Cell Complete Following Indexing Use Forwa Q43904170

Python Programming

Q6: Indexing (0.5 points) Using the four lists provided in the cell below, complete the following indexing: • Use forward ind

Q6: Indexing (0.5 points) Using the four lists provided in the cell below, complete the following indexing: • Use forward indexing to store the second value in list_1 to index_1 . Use negative indexing to store the last value in list_2 to index_2 • Store the first three values of list_3 to index_3 • Store the last two values of list_4 to index_4 In [85]: # provided for you list_1 = (10, 20, 30, 40 list_2 = (13, 15, 17, 19, 21, 23] list_3 = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] list_4 = (21, 9, 98, 289, 938] In [92]: # YOUR CODE HERE In [93]: assert isinstance(index_1, int) assert isinstance(index_2, int) assert isinstance(index_3, list) assert isinstance(index_4, list) Q10: Putting it all together (0.75 points) Here, we’ll update the values in dictionary, storing the output in a dictionary called other_dictionary. This new dictionary will have the same keys, but some values will be updated. The values in other_dictionary should be updated, such that if the value in the original dictionary is… • odd: update the the value stored in the dictionary to store the squared difference of the original value and ’10’. • even: store the original value (from dictionary ). Hints: 1. to loop through key-value pairs in a dictionary, check out the .items method 2. You created a squared_diff function above, In [ ]: # run this cell to remind yourself what is stored in dictionary dictionary.items() In [ ]: # YOUR CODE HERE In [ ]: assert other_dictionary # There are hidden tests that check the contents of ‘other_dictionary’. Show transcribed image text Q6: Indexing (0.5 points) Using the four lists provided in the cell below, complete the following indexing: • Use forward indexing to store the second value in list_1 to index_1 . Use negative indexing to store the last value in list_2 to index_2 • Store the first three values of list_3 to index_3 • Store the last two values of list_4 to index_4 In [85]: # provided for you list_1 = (10, 20, 30, 40 list_2 = (13, 15, 17, 19, 21, 23] list_3 = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] list_4 = (21, 9, 98, 289, 938] In [92]: # YOUR CODE HERE In [93]: assert isinstance(index_1, int) assert isinstance(index_2, int) assert isinstance(index_3, list) assert isinstance(index_4, list) Q10: Putting it all together (0.75 points) Here, we’ll update the values in dictionary, storing the output in a dictionary called other_dictionary. This new dictionary will have the same keys, but some values will be updated. The values in other_dictionary should be updated, such that if the value in the original dictionary is… • odd: update the the value stored in the dictionary to store the squared difference of the original value and ’10’. • even: store the original value (from dictionary ). Hints: 1. to loop through key-value pairs in a dictionary, check out the .items method 2. You created a squared_diff function above, In [ ]: # run this cell to remind yourself what is stored in dictionary dictionary.items() In [ ]: # YOUR CODE HERE In [ ]: assert other_dictionary # There are hidden tests that check the contents of ‘other_dictionary’.

Expert Answer


Answer to Q6: Indexing (0.5 points) Using the four lists provided in the cell below, complete the following indexing: • Use forw…

OR