NEW
Font size
WorksheetsLists in Python
Total questions: 20
Worksheet time: 9mins
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]
List items have an index number. In the following list, which item has the index number of 3?
["John", "Harry", "Jesse", "John", "Harry", "Harry"]
"John"
"Harry"
"Jesse"
"John"
What is a list in python?
A collection of variables
A collection of items assigned to a single variable
A statement that cant be changed
A Christmas list
What is the index number for 'Spain'?
['England','Brazil','Spain','France']
0
1
2
3
Which code would i use to add an item to a list?
variable.add()
variable.append()
append.variable()
add.variable()
Why is using lists beneficial?
Shorter Code
More Accurate
It takes less time for the program to run
Its not beneficial
What sort of loop is this?
Count Controlled
Condition Controlled
What is the output of the program below?
mariana_islands = ['Guam', 'Saipan', 'Tinian', 'Rota']
cmni = mariana_islands[1:]
len(cmni)
1
2
3
4
What would this code do?
Remove the name "Felipe" from the list
Remove the first copy of "John" from the list
Remove the name "Felipe" from the list and print it out to the shell
An error
An empty list can be declared as
fruitList = ""
fruitList = ["empty"]
fruitList == []
fruitList = []
1. A list is ------------------------------ data type
sequence
selection
iteration
None of hese
List need not be always----------------------------------------
Non Homogeneous
Homogeneous
sequence
selective
1. Lists are indexed by an ----------------------------------------------
decimal
neither integer nor dcimal
integer
fraction
1. Lists are ---------------------------------, you can update or edit the list
Immutable
Mutable
Both
None of these
1.In a list elements are enclosed in----------------------------------
square bracket
curly bracket
parenthesis
None of these
-------------------method is used to delete elements from a list if index is not known
pop
push
remove
insert
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"])
What is the function of the reverse method for lists?
removes the first occurrence of the information inside the parenthesis
adds the information inside the parenthesis to the end of the list
reverses the order of the elements inside a list
sorts the list (lowest to highest for numbers and alphabetical order for strings)
To print a list called fruitList we use
print(fruitList)
list(print)
fruitList.print()
fruitList(print)
