In: Computer Science
Please solve everything using Python 3
1. What does list contain after the following code is executed?
list = [82, 27, 66, 18, 40, 93, 85, 29]
list.append(50)
list.insert(3, 99)
list.pop()
a. [82, 27, 66, 99, 18, 40, 93, 85, 29]
b. [50, 82, 27, 99, 66, 18, 40, 93, 85]
c. [27, 66, 99, 18, 40, 93, 85, 29, 50]
d. [82, 27, 99, 66, 18, 40, 93, 85, 29]
2. What does list contain after the following code is executed?
list = [77, 41, 92, 30, 38, 12, 63]
list.sort()
list.insert(2, 88)
list.pop(5)
a. [12, 30, 88, 38, 63, 77, 92]
b. [92, 77, 88, 63, 41, 30, 12]
c. [12, 88, 30, 38, 63, 77, 92]
d. [12, 30, 88, 38, 41, 77, 92]
3. What does the list states contain after the following code is executed?
states = ['NJ', 'TN', 'WI', 'UT']
states.extend(['PA', 'KY', 'NY'])
states.remove('UT')
states.sort(reverse=True)
a. ['WI', 'UT', 'TN', 'PA', 'NY', 'NJ', 'KY']
b. ['WI', 'PA', 'TN', 'NJ', 'NY', 'KY']
c. ['WI', 'TN', 'PA', 'NY', 'NJ', 'KY']
d.['NJ', 'TN', 'WI', 'PA', 'KY', 'NY']
1)Solution is (a) methods are explained below one by one as comments.
2)Solution is (d) methods are explained below one by one as comments.
3)Solution is (c) methods are explained below one by one as comments.