Font size
WorksheetsProgramming in Python, Lists - 9RH
Total questions: 17
Worksheet time: 12mins
people = ["John", "Rob", "Bob"]
print (people[1])
what would this result be?
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", "Jeremy", "Tom"]
"John"
"Harry"
"Jesse"
"Jeremy"
Which of these pieces of code would return the name "Harry" from the following list?
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList()
nameList[1]
NameList(4)
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)
append(nameList,"Felipe")
nameList.append["Felipe",7]
nameList.append("Felipe")
To print a list called fruitList we use
print(fruitList)
list(print)
fruitList.print()
fruitList(print)
Which symbols are used to open and close a list?
( ) round brackets
( ) curly brackets
[ ] square brackets
" " speech marks
Why is programming important, even if you do not plan to work in computer science? (Multiple answers)
It contributes towards computational thinking and problem solving
We are surrounded by technology, understanding how it works reveals more to us about the world
We rely heavily on technology, we need to understand how to adapt in the future
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
What would this code show on the screen?
7
6
5
4
An error
Which of these is a list?
["apples", "oranges", "bananas"]
"apples", "oranges", "bananas"
{"apples", "oranges", "bananas"}
("apples", "oranges", "bananas")
Which of these assigns a list to a variable?
fruit = input(["apples", "oranges", "bananas"])
fruit = ["apples", "oranges", "bananas"]
fruit == ["apples", "oranges", "bananas"]
fruit["apples", "oranges", "bananas"]
To insert an item in the first position of a list we use
fruit.append("strawberries, 1")
fruit.insert("strawberries",0)
fruit.insert(1, "strawberries")
fruit.insert(0, "strawberries")
An empty list can be declared as
fruitList = ""
fruitList = ["empty"]
fruitList == []
fruitList = []
