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 10:30
Auniversity wants to install a client-server network. which feature do you think is important for them as they set up the network? sending email blocking multiple people to use the same file low security low set up cost limited access to files
Answers: 1
question
Computers and Technology, 23.06.2019 03:50
Iam a bacterium. i cause stomach cramps and diarrhea. i am caused by eating rotten foodssuch as chicken, fish, or eggs. sometimes turtles carry my bacteria.what am i?
Answers: 2
question
Computers and Technology, 23.06.2019 19:30
Amitha writes up a one-page summary of a novel during her summer internship at a publishing company. when she reads over the page, she realizes she used the word “foreshadow” seven times, and she would like to reduce the repetition. which tool would best amitha solve this problem?
Answers: 3
question
Computers and Technology, 24.06.2019 13:30
Type the correct answer in the box. spell all words correctly. what is the default margin width on all four sides of a document? by default, the document has a margin on all four sides.
Answers: 1
You know the right answer?
Working With Collections This part covers working with collections and indexing.
In [ ]: #...
Questions
Questions on the website: 13722363