WorksheetsNTRC DAY 4 QUIZ
Total questions: 20
Worksheet time: 34mins
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"
Is this the correct code for a list?
register = {"Sam", "Pheobe", Georgia", Richard"}
Yes
No
Consider this list, what will be the highest index the list can have:
li=[1,2,3,4,5]
2
3
4
5
What is the index of “grape” in the list
[“apple”, “grape”, “orange”, “watermelon”]?
0
1
2
3
mylist = ["a","b"]
mylist[1] = "c"'
print(mylist)
["a","c"]
["a","b"]
["a","b","c"]
mylist
In a list called "players" if you wanted to delete the item with an index of 3 which of the following examples of code would be correct?
players.pop[3]
players.delete(3)
players.remove(3)
players.pop(3)
list1 = ["hello", "hey", "hi"]
print(list1)
How many items will be printed?
1
2
3
0
Which of the following keywords marks the beginning of the function block?
Func
define
def
function
What character should be placed at the end of the function "def" line, after the parentheses?
Hashtag (#)
Colon(:)
Exclamation (!)
Dash (-)
The program above
prints all the odd numbers between 1 and 20
prints all even numbers between 1 and 20
print all the odd numbers between 1 and 21
prints all the even numbers between 1 and 21
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 purpose of a return statement?
It prints the output of the function.
It stops the function from executing further.
It defines the input parameters of the function.
It specifies the value to be returned by the function
What is a function in Python?
a) A single value representing a piece of data.
b) A block of code that performs a specific task and can be reused throughout the program
c) A built-in module that provides mathematical functions.
d) An error that occurs when the program encounters an unexpected condition.
What is the output of the expression (4+2)==6 OR 3<2?
True
False
The "and " operator runs true if
