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, 21.06.2019 19:30
Can you make money in why are you guys so
Answers: 1
question
Computers and Technology, 21.06.2019 20:50
Write a method in the heapintpriorityqueue class called merge that accepts another heapintpriorityqueue as a parameter and adds all elements from the other queue into the current queue, maintaining proper heap order such that the elements will still come out in ascending order when they are removed. your code should not modify the queue passed in as a parameter. (recall that objects of the same class can access each other's private fields.)
Answers: 2
question
Computers and Technology, 23.06.2019 00:10
Write a function so that the main0 code below can be replaced by the simpler code that calls function mphandminutes tomiles0. original main0 int main) l double milesperhour-70.0; double minutestraveled = 100.0; double hourstraveled; double milestraveled; hourstraveled = minutestraveled / 60.0; milestraveled = hourstraveled * milesperhour; cout < "miles" 2 using namespace std; 4 /* your solution goes here/ 6 int maino 1 test passed 7 double milesperhour 70.0 all tests passed 8 double minutestraveled 100.0; 10 cout < < "miles: " < < mphandminutestomiles(milesper-hour, minutestraveled) < < endl; 12 return 0; 13
Answers: 1
question
Computers and Technology, 23.06.2019 10:00
How do i delete my account on this because i didn't read this agreements and also i put age at xd
Answers: 1
You know the right answer?
Working With Collections This part covers working with collections and indexing.
In [ ]: #...
Questions
question
Social Studies, 07.10.2019 23:30
question
Mathematics, 07.10.2019 23:40
question
Chemistry, 07.10.2019 23:40
question
History, 07.10.2019 23:40
Questions on the website: 13722360