WorksheetsPython list TIK
Total questions: 40
Worksheet time: 20mins
Which is not a definition about lists?
Lists are used to store multiple STRINGS in a single variable.
Lists are used to store multiple ITEMS in a single variable.
Lists are used to store multiple INTIGERS in a single variable.
Lists are used to store multiple ICONS in a single variable.
Which is not a property of the lists?
Allow duplicates
Changeable
Ordered
Unchangeable
Which is the code to print the number of items in the list called "names" in Python:
names=["era", "beni", "hena","mikael", "ana" ]
print(list)
print(len(list))
cout>>list
cin<<list
Use a range of indexes to print the third, fourth, and fifth item in the list.
fruits = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
print(fruits[2:5])
print(fruits[:5])
print(fruits[0:5])
print(fruits[5])
Use negative indexing to print the last item in the list.
fruits = ["apple", "banana", "cherry"]
print(fruits[1])
print(fruits[0])
print(fruits[-1])
print(fruits[0:5])
Use the remove method to remove "banana" from the fruits list.
fruits = ["apple", "banana", "cherry"]
fruits.remove
("banana")
fruits.remove
("apple")
fruits.remove
("kiwi")
fruits.remove
("mango")
Change the value from "apple" to "kiwi", in the fruits list.
fruits = ["apple", "banana", "cherry"]
friuts[5]="kiwi"
friuts[2]="kiwi"
friuts[0]="kiwi"
friuts[1]="kiwi"
Use the append method to add "orange" to the fruits list.
fruits = ["apple", "banana", "cherry"]
fruits.append
([1]=orange)
fruits.append
(2=orange)
fruits.append
(1=orange)
fruits.append
("orange")
Use the insert method to add "lemon" as the second item in the fruits list.
fruits = ["apple", "banana", "cherry"]
fruits.insert
(index2,"lemon")
fruits.insert
(1,"lemon")
fruits.insert
(2,"lemon")
fruits.insert
(second,"lemon")
Print the second item in the fruits list.
fruits = ["apple", "banana", "cherry"]
print(friuts<1>)
print(friuts[1])
print(friuts{1})
print(friuts(1))
Which data type are the items of the list below:
list1 = ["apple", "banana", "cherry"]
String
Intiger
Boolean
friuts
Which data type are the items of the list below:
list2 = [1, 5, 7, 9, 3]
text
bytes
Intigers
bits
Which data type are the items of the list below:
list3 = [True, False, False]
Numbers
String
Boolean
Charachter
Which symbols are used to open and close a list?
{ }
[ ]
( )
< >
What is the position of the name "Robert" in the following list?
name=["Bob","Robert","Bobby","Rob"]
0
1
2
3
To print a list called "fruitList" we use:
fruitList.print()
list(print)
friutList(print)
print(fruitList)
Select all the correct options to join two lists in Python
listOne = ['a', 'b', 'c', 'd']
listTwo = ['e', 'f', 'g']
newList = list1 + list1
newList = list2 + list2
newList = listOne + listTwo
newList = list1 + list2
What is the output of the following list function?
sampleList = [10, 20, 30, 40, 50]
sampleList.append(60)
print(sampleList)
[10, 20, 30, 40, 50, 60]
[10, 20, 60, 30, 40, 50,]
[60, 10, 20, 30, 40, 50]
[10, 20, 30, 40, 60, 50]
If list1=[6, 23, 3, 2, 0, 9, 8, 75]
Which of the following will give output as [3, 2, 0]
print(list1[0:5])
print(list1[1:5])
print(list1[2:5])
print(list1[3:5])
___________ method adds one list at the END of another list.
insert( )
append( )
extend( )
join( )
____________function can be used to insert an element/object at a specified index.
insert( )
append( )
extend( )
remove( )
____________function can be used to insert
an element/object at a specified index.
insert( )
append( )
extend( )
remove( )
___________method adds a single item to the end of the list.
insert( )
append( )
extend( )
remove( )
Which of these is the correct code for creating a list of names?
nameList = John, Harry, Jesse, John, Harry, Harry
nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList = [John, Harry, Jesse, John, Harry, Harry]
Which of these pieces of code would return the name "Harry" from the following list?
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList()
NameList(4)
nameList[1]
nameList["4"]
The list needs one more name added to the end - "Felipe".
Which piece of code below would do this?
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList.append(Felipe)
nameList.append("Felipe")
append(nameList,"Felipe")
nameList.append["Felipe",7]
nameList = ["John", "Harry", "Jesse", "John", "Marry", "Larry"]
The list will be slice and show Harry and Jesse only. Which piece of code below would do this?
print(nameList[1:3])
print(nameList[0:1])
print(nameList[1:2])
print(nameList["Harry":"Jesse"])
To insert an the string "Pedro" in the first position of a the nameList we use:
nameList.append("Pedro, 1")
nameList.insert("Pedro",0)
nameList.insert(1, "Pedro")
nameList.insert(0, "Pedro")
What is the output of program below?
mariana_islands = ['Saipan', 'Tinian', 'Rota']
mariana_islands.pop()
print(mariana_islands)
['Saipan', 'Tinian', 'Rota']
['Tinian', 'Rota']
['Saipan', 'Tinian']
['Saipan', 'Rota']
What is the output of program below?
mariana_islands = ['Saipan', 'Tinian', 'Rota']
mariana_islands.remove('Tinian')
print(mariana_islands)
['Saipan', 'Tinian', 'Rota']
['Tinian', 'Rota']
['Saipan', 'Tinian']
['Saipan', 'Rota']
What is the output of program below?
mariana_islands = ['Saipan', 'Tinian', 'Rota', 'Guam']
mariana_islands.sort()
print(mariana_islands)
['Guam', 'Tinian', 'Rota', 'Saipan']
['Guam', 'Rota', 'Saipan', 'Tinian']
['Saipan', 'Rota', 'Guam', 'Tinian']
['Tinian', 'Saipan', 'Rota', 'Guam']
What is the output of program below?
mariana_islands = ['Saipan', 'Tinian', 'Rota']
mariana_islands.insert(0, 'Guam')
print(mariana_islands)
['Saipan', 'Tinian', 'Rota']
['Guam', 'Tinian', 'Rota']
['Saipan', 'Tinian', 'Rota', 'Guam']
['Guam', 'Saipan', 'Tinian', 'Rota']
What is the output of program below?
mariana_islands = ['Saipan', 'Tinian', 'Rota']
mariana_islands.append('Guam')
print(mariana_islands)
['Saipan', 'Tinian', 'Rota']
['Guam', 'Tinian', 'Rota']
['Saipan', 'Tinian', 'Rota', 'Guam']
['Guam', 'Saipan', 'Tinian', 'Rota']
What is the output of program below?
mariana_islands = ['Saipan', 'Tinian', 'Rota']
mariana_islands[3] = 'Guam'
print(mariana_islands)
['Saipan', 'Tinian', 'Rota']
['Guam', 'Tinian', 'Rota']
['Saipan', 'Tinian', 'Rota', 'Guam']
['Guam', 'Saipan', 'Tinian', 'Rota']
What is the output of program below?
mariana_islands = ['Guam', 'Saipan', 'Tinian', 'Rota']
print(mariana_islands[-1])
Guam
Saipan
Tinian
Rota
What is the output of program below?
mariana_islands = ['Guam', 'Saipan', 'Tinian', 'Rota']
print(mariana_islands[1])
Guam
Saipan
Tinian
Rota
What is the output of the program below?
mariana_islands = ['Guam', 'Saipan', 'Tinian', 'Rota']
print(len(mariana_islands))
4
3
2
1
Given a list numbers=[10,20,30,40,50,60,70,80]
What would numbers[2:6] return?
[10,20,30,40]
[20,30,40,50]
[20,30,40]
[30,40,50,60]
What output will this code produce?
blue
green
red
yellow
What output will this code?
[2,4,6,8,10]
['2','4','6','8','10']
[0,2,4,6,8]
[10,8,6,4,2]
