wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python strings and lists

Total questions: 12

Worksheet time: 8mins

Name
Class
Date
1.

Which of the operator can be used in Strings?

a)

+

b)

*

c)

Both of the above

d)

None of the above

2.

When we create a program to extract each alphabet from a given string, what is it known as?

a)

Transpose

b)

Traverse

c)

Translate

d)

Terminate

3.

Which method is used to convert a given string in Capital letters?

a)

Capital

b)

Upper

c)

ConverttoUpper

d)

Capitalize

4.

Which of the following is not a valid string function?

a)

isalphanumeric

b)

isspace

c)

islower

d)

isalnum

5.

s1="Hello"

n1=10

print(s1+n1)

What is the error in this code?

a)

Print statement not written in quotes

b)

Numeric value not written in quotes

c)

colon not written after the print statement

d)

string cannot be added to a number

6.

Which brackets are used for Lists?

a)

( )

b)

[ ]

c)

{ }

d)

None of the above

7.

[1, 2, 8, 9] < [9, 1]


What will be the result if we compare these two lists?

a)

True

b)

False

8.

[1, 2, 8, 9] < [1, 2, 8, 4]


What will be the result if we compare these two lists?

a)

True

b)

False

9.

Suppose you have the following tuple definition:


t = ('foo', 'bar', 'baz')


Which of the following statements replaces the second element ('bar') with the string 'qux':

a)

t[1] = 'qux'

b)

t(1) = 'qux'

c)

t[1:1] = 'qux'

d)

It’s a trick question—tuples can’t be modified.

10.

If list1=[10,20,30,40,50]

then list1[2]=35 will result in:

a)

[35,10,20,30,40,50]

b)

[10,20,30,40,50,35]

c)

[10,20,35,40,50]

d)

[10,35,30,40,50]

11.

If list1=[17,23,41,10]

then list1.append(32) will result in:

a)

[32,17,23,41,10]

b)

[17,23,41,10,32]

c)

[10,17,23,32,41]

d)

[41,32,23,17,10]

12.

Can lists contain tuples and vice versa?

a)

Yes

b)

No