WorksheetsPython Unit 6 Sequences Quiz
Total questions: 20
Worksheet time: 10mins
For strings, the + operator represents
Concatenation
Addition
Appending
Recantation
data = "No Way!" The expression len(data) evaluates to:
7
9
8
6
Which of code is correct for creating a list of numbers?
num = (10,29,37,109)
num = [10,29,37,109]
num == (10,29,37,109)
num = ['10 29 37 109']
What is used to separate elements in a list?
Bracket
Comma
Full Stop
Space
The correct syntax of the len function for string x:
x.len()
len[x]
LEN[]
len(x)
The correct syntax for converting the string x to uppercase is :
upper.x()
upper(x)
x.UPPER[ ]
x.upper()
x= "JavaLava", the output of print( x[len(x): ] ) is
a
Error. Index out of range
JavaLava
J
Let x= "python is a high level language", the output of print(x[5].replace("n","*")) is
pytho* is a high level language
python is a high level language
*
Error
Let x= "python is a high level language", the output of print(len(x[-1])) is
1
31
Error
25
Let x= "Python is a high level language", the output of print(x[2].upper()+x[3].lower()+x[-1]) is
THE
The
ThE
the
Given s = "Python", choose the Python code that DOES NOT give the output 6
print(len(s))
print(s.len())
print(s.replace("Python","6"))
print(len(s[ : len(s)] ))
Let x= "Python", the output of
print(x[0])
print(x[-1])
print(x[-2])
P
N
O
p
O
n
t
h
y
P
n
o
Which of the following functions is used to count the number of elements in a list ?
count( )
find( )
len( )
index( )
Let list1=[2,4,6,8,10] then print(list1[-2]) will result in
10
8
4
6
If list=[10,20,30,40,50] then list[2]=35 will result
[35,10,20,30,40,50]
[10,20,30,40,50,35]
[10,20,35,40,50]
[10,35,30,40,50]
If list=[17,23,41,10] then list.append(32) will result
[32,17,23,41,10]
[17,23,41,10,32]
[10,17,23,32,41]
[41,32,23,17,10]
What type of data is: a=[(1,1),(2,4),(3,9)]?
Array of tuples
List of tuples
Tuples of lists
Invalid type
If L1=[2, 4, 8, 16] and L2=[32, 64]
what will result from L1+L2?
[2,4,8,16,32,64]
[2,4,8,16][32,64]
[2,4,8,16],[32,64]
2468163264
What is the index number for 'Spain'?
['England','Brazil','Spain','France']
0
1
2
3
Let x= "JavaLava", the output of print(x.rfind("v") ) is
3
6
2
7
