PYTHON Assume you have the following list named myList [10, 55, 67, 3, 12, 89] U
ID: 3756020 • Letter: P
Question
PYTHON
Assume you have the following list named myList
[10, 55, 67, 3, 12, 89]
Using the methods, functions and statements of chapter 3 to manipulate the list myList write the code that will produce the following printed statements (which will be print(myList)):[10, 55, 67, 3, 12, 89]
[10, 55, 67, 3, 12, 89, 100]
[10, 55, 67, 3, 12, 89, 100, 44]
[10, 55, 67, 3, 44, 12, 89, 100, 44]
[23, 10, 55, 67, 3, 44, 12, 89, 100, 44]
[44, 23, 10, 55, 67, 3, 44, 12, 89, 100]
[44, 23, 10, 55, 67, 44, 12, 89, 100]
[44, 23, 89, 55, 67, 44, 12, 10, 100]
[44, 23, 55, 67, 44, 12, 10, 100]
[44, 23, 10, 67, 44, 55, 12, 100]
[10, 44, 23, 67, 44, 55, 12, 100]
[10, 12, 23, 44, 55, 67, 100]
[100, 67, 55, 44, 23, 12, 10]
Please make the first line of your code:
myList = [10, 55, 67, 3, 12, 89]
Explanation / Answer
myList = [10, 55, 67, 3, 12, 89]
print(myList)
myList.append(100)
print(myList)
myList.append(44)
print(myList)
myList = myList[:4] + [44] + myList[4:]
print(myList)
myList = [23] + myList
print(myList)
myList = [myList[-1]] + myList[:-1]
print(myList)
del myList[5]
print(myList)
myList[-2], myList[2] = myList[2], myList[-2]
print(myList)
del myList[2]
print(myList)
myList[2], myList[5], myList[6] = myList[-2], myList[2], myList[-3]
print(myList)
myList = [myList[2]] + myList[:2] + myList[3:]
print(myList)
myList.sort()
print(myList)
myList = myList[::-1]
print(myList)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.