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 17:00
Your computer running windows 10 is doing some very strange things with the operating system. you are fairly certain it is not a hardware issue. you need to try to get further insight into what is going on within the operating system. which tool would be best suited for this?
Answers: 2
question
Computers and Technology, 23.06.2019 03:30
Many everyday occurrences can be represented as a binary bit. for example, a door is open or closed, the stove is on or off, and the fog is asleep or awake. could relationships be represented as a binary value? give example.
Answers: 1
question
Computers and Technology, 23.06.2019 10:00
Now, open this passage to read about fafsa requirements. describe the information you will need to provide in order to complete a fafsa. list at least three of the required documents you must include.
Answers: 3
question
Computers and Technology, 23.06.2019 12:00
From excel to powerpoint, you can copy and paste a. cell ranges and charts, one at a time. b. cell ranges and charts, simultaneously. c. charts only. d. cell ranges only.
Answers: 3
You know the right answer?
Working With Collections This part covers working with collections and indexing.
In [ ]: #...
Questions
question
English, 17.06.2021 22:00
question
English, 17.06.2021 22:00