subject

Working With Collections This part covers working with collections and indexing.
In [ ]: # For Q1 & Q2, the following lists are provided for you
list_l = [10, 20, 40, 501
list_2 = [13, 15, 17, 19, 22, 25]
list_3 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
list_4 = [21, 9, 98, 289, 938
Q1 - Indexing
Do the following using indexing
. Store the first value in list1 to index1
. Store the last value in list_2 to index_2
. Store the first four values of list_2 to index_3
. Store the last four values of list_3 to index_4
In [ ]: # YOUR CODE HERE
In [ ]: assert isinstance(index 1, int)
In [ ]: assert isinstance(index_2, int)
In [ ]: assert isinstance(index_3, list)
assert len(index 3)4
In [ ]: assert isinstance(index 4, list)
assert len(index 4) 4
2. Do the following comparisons using indexing:
Check if the second value of list_1 is one of the last three values in list_3 (Hint: remember operator in)
Store the result in comp_result_1
Check if the third value of list_4 is greater than the fourth value in list_4
Store the result in comp_result_2
Check if the last value of list_4 is less than the second value in list_4
Store the result in comp_result_3
Check if the second value of list_2 multiplied by the fifth value of list_3 is less than the second to last value in list_4
Store the result in comp_result_4
Keep in mind that you are storing the result of a comparison to a variable, so resulting variables should all be booleans.
In [ ]: # rOUR CODE HERE
In [ ]: In assert isinstance (comp_result_1, bool)
In [ ]: In assert isinstance(comp_result_2, bool)
In [ ]: In assert is instance(comp_result 3, bool)
In [ ]: In : assert isinstance(comp_result 4, bool)

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 09:50
Assume that you have an sorted array of records. assume that the length of the array (n) is known. give two different methods to search for a specific value in this array. you can use english or pseudo-code for your algorithm. what is the time complexity for each algorithm and why?
Answers: 1
question
Computers and Technology, 24.06.2019 06:00
Hey i really need some solving this problem: 1. encrypt this binary string into cipher text: 110000. include in your answer the formula the decoder would use to decrypt your cipher text in the format (coded answer) x n mod (m) = y & 2. decrypt this cipher text into a binary string: 106 you.
Answers: 2
question
Computers and Technology, 24.06.2019 20:00
Avirus enters a computer or network as code embedded in other software directly from another computer
Answers: 1
question
Computers and Technology, 24.06.2019 22:00
Is the process of organizing data to reduce redundancy. a. normalization b. primary keying c. specifying relationships d. duplication
Answers: 1
You know the right answer?
Working With Collections This part covers working with collections and indexing.
In [ ]: #...
Questions
question
History, 05.07.2019 08:20
question
History, 05.07.2019 08:20
question
Mathematics, 05.07.2019 08:20
question
Mathematics, 05.07.2019 08:20
question
Mathematics, 05.07.2019 08:20
Questions on the website: 13722360