NEW
Font size
WorksheetsPython Review
Total questions: 16
Worksheet time: 8mins
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"
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"]
This list contains items of what data type?
String
Boolean
Float
Integer
Which symbols are used to open and close a list?
( ) round brackets
( ) curly brackets
[ ] square brackets
" " speech marks
variable.sort() will do what?
Sort the list into alphabetical order
Sort the list into reverse order
Create a new list
Error
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)
nameList = ["John", "Harry", "Jesse", "John", "Marry", "Larry"]
del nameList[3]
print(nameList)
What would be the output
['John', 'Harry', 'Jesse', 'Marry', 'Larry']
['John', 'Harry', 'Jesse', 'John', 'Larry']
['John', 'Harry', 'John', 'Marry', 'Larry']
Error
What will be the output?
name = "Dave"
print (name)
Dave
'Dave'
name
(name)
What is the resulting value of x?
double x;
x = 2.3
2
2.3
Error
What is the resulting value of x?
int x;
x = 2.3;
Error
2
2.3
What is the resulting value of x?
double x;
x = 7;
Error
7
7.0
What data type for a constant called: PI = 3.14
STRING
INTEGER
FLOAT
BOOLEAN
What data type to store the price of a CD?
STRING
INTEGER
FLOAT
DATE
What data type for a car plate number: plateNumber = "AV01-AFP"?
STRING
INTEGER
FLOAT
DATE
