Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

list sort and concatenation

Total questions: 9

Worksheet time: 5mins

Name
Class
Date
1.

Which of the following Python code print the list X in a reverse order

a)

a) print(X.reverse ())

b)

b) X.sort(reverse= FALSE)

print(X)

c)

c) print(X[: : -1])

d)

d) b and c.

2.

Which of the following Python code sort the list X in an ascending order:

a)

sort.X( )

b)

X.sort[ ]

c)

X.sort(reverse = True)

d)

X.sort( )

3.

Which of the following python code adds the List 1 as an extension to the original List 2

a)

a) List1.extend(List2)

b)

b) List2.extend(List1)

c)

c) List1.append(List2)

d)

d) a and c.

4.

Let x= "17" and y=["My age is"], the output of print(x + y) is ["My age is", "17"]

a)

True

b)

False

5.

Which of the following Python code sort the list x in an descending order:

a)

x.reverse ( )

b)

x.sort( )

c)

x.sort(key = len)

d)

x.sort(reverse = True)

6.

let x = [2,5,0,8,9], the output of the following Python code is

x.reverse( )

print(x[0])

x.sort(key=len)

print(x)

a)

9

Error

b)

2

[9, 8, 0,5,2]

c)

9

[0, 2, 5, 8, 9]

d)

2

[0, 2, 5, 8, 9]

7.

let x= ["my name is"] and y = "Ali", which of the following Python code will print my name is Ali as a string

a)

print(x +[ y ])

b)

print(str(x) + y)

8.

Let x= ["my name is"] and y = ["Ali"], the output of the following Python code is

print(x + y)

print(x)

x.extend(y)

print(x)

a)

['my name is', 'Ali']

['my name is', 'Ali']

['my name is', 'Ali']

b)

['my name is Ali']

['my name is']

['my name is', 'Ali']

c)

['my name is', 'Ali']

['my name is']

['my name is', 'Ali']

9.

let x= ["my name is"] and y = "Ali", the output of the following Python code is

print(str(x) + y)

a)

['my name is']Ali

b)

["my name is", "Ali"]

c)

"my name is Ali"