Write the code to create an empty list named myList
myList = []
The following list has been been created:
lunchFood = ["nachos", "pizza", "soup"]
What is lunchFood[0]?
"nachos"
myNumbers = [10, 20, 25]
Evaluate the following expression:
5 * myNumbers[0]
50
myNumbers = [5, 10, 15, 20]
What does the list myNumbers contain after running the code below?
myNumbers.remove(10)
[5, 15, 20]
Write the code to create a list named breakfastFood that contains the strings "bacon", "eggs", and "cereal"
breakfastFood = ["bacon", "eggs", "cereal"]
The following list has been been created:
lunchFood = ["nachos", "pizza", "soup"]
What is lunchFood[len(lunchFood)-1]?
"soup"
myNumbers = [10, 20, 25]
Evaluate the following expression:
myNumbers[2] - myNumbers[1]
5
myNumbers = [5, 10, 15, 20]
What does the list myNumbers contain after running the code below?
del myNumbers[1]
[5, 15, 20]
Write the code to create a list named primeNumbers that contains the first five prime numbers
primeNumbers = [2, 3, 5, 7, 11]
The following list has been been created:
lunchFood = ["nachos", "pizza", "soup"]
What is lunchFood[len(lunchFood)]?
IndexError: list index out of range
myStuff = ["mouse","cheese",5,2]
myStuff[myStuff[3]] = myStuff[0]
myStuff[0] = "house"
What is contained in the list myStuff after this program has run?
["house","cheese",5,"mouse"]
myNumbers = [5, 10, 15, 20]
What does the list myNumbers contain after running the code below?
myNumbers.append(25)
myNumbers.insert(1,50)
[5, 50, 10, 15, 25]
A list named myNums has already been created and initialized with four values.
Write the code to create a new list named myNums2 that contains the same elements as myNums but in reversed order (ex: if myNums = [1,2,3,4] then myNums2 should equal [4,3,2,1])
myNums2 = [myNums[3], myNums[2], myNums[1], myNums[0]]
The following list has been created in code:
numbers = [5, 3, 10, 2, 1]
What is numbers[numbers[1]]?
2
nums = [3, 7, 15, 1]
nums[0] = nums[len(nums)-1]
nums[1] = nums[len(nums)-2]
What is contained in the list nums after this program has run?
[1, 15, 15, 1]
myNumbers = [5, 10, 15, 20]
What does the list myNumbers contain after running the code below?
del myNumbers[2]
myNumbers.append(myNumbers[2])
[5, 10, 20, 20]
Two lists have already been created in the code:
firstNames = ["John", "Marie", "Jia"]
and
lastNames = ["Martinez", "Lee", "Jones"]
Write the code to create a new list called names that contains the corresponding first name/ last name pairs. Ex: The first element should contain "John Martinez"
names = [firstNames[0] + " " + lastNames[0], firstNames[1] + " " + lastNames[1], + firstNames[2] + " " + lastNames[2]]
The following list has been created in code:
numbers = [5, 3, 10, 2, 1]
What is numbers[len(numbers)-numbers[len(numbers)-1]]?
1
nums = [3, 7, 15, 1]
temp = nums[0]
nums[0] = nums[len(nums)-1]
nums[len(nums)-1] = temp
temp = nums[1]
nums[1] = nums[len(nums)-2]
nums[len(nums)-2] = temp
What is contained in the list nums after this program has run?
[1, 15, 7, 3]
bList = ["to", 5, "po"]
bList.append(bList[2] + "ta" + bList[0])
bList.insert(2-1, "go")
bList.remove(5)
What does the list bList contain at the end of this program?
["to", "go", "po", "potato"]