wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

String and List

Total questions: 14

Worksheet time: 7mins

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.

word = "amazing"

For the given string if we run word[2:5] what does it mean?

a)

It will extract alphabets from index 2 to index 4

b)

It will extract alphabets from index 2 to index 5

c)

It will extract alphabets from position 2 to position 4

d)

It will extract alphabets from position 2 to position 5

3.

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

a)

Capital

b)

Upper

c)

ConverttoUpper

d)

Capitalize

4.

s1="Hello"

s2="10"

print(s1+n1)

What is the error in this code?

a)

String 2 written in quotes

b)

String cannot be multiplied with a string

c)

colon not written after print statement

d)

Number written in quotes

5.

Which method is used to add a value at a specified position in the list?

a)

append

b)

extend

c)

insert

d)

pop

6.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Jesse, John, Harry, Harry

b)

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

c)

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

d)

nameList = [John, Harry, Jesse, John, Harry, Harry]

7.

List items have an index number. In the following list, which item has the index number of 3?

["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

"John"

b)

"Harry"

c)

"Jesse"

d)

"John"

8.

Which of these pieces of code would return the name "Harry" from the following list?

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

nameList()

b)

nameList[1]

c)

NameList(4)

d)

nameList["4"]

9.
What is the position of the name "Robert" in the following list:
a)
0
b)
1
c)
2
d)
3
10.
What output will this code produce?
a)
blue
b)
green
c)
red
d)
error
11.

To insert an the string "strawberries" in the first position of a list we use

a)

fruit.append("strawberries, 1")

b)

fruit.insert("strawberries",0)

c)

fruit.insert(1, "strawberries")

d)

fruit.insert(0, "strawberries")

12.
What output will this code produce?
a)
red
b)
['blue', 'green', 'red']
c)
['red', 'green', 'blue']
d)
error
13.

variable.sort() will do what?

a)

Sort the list into alphabetical order

b)

Sort the list into reverse order

c)

Create a new list

d)

Error

14.

nameList = ["John", "Harry", "Jesse", "John", "Marry", "Larry"]

del nameList[3]

print(nameList)

What would be the output

a)

['John', 'Harry', 'Jesse', 'Marry', 'Larry']

b)

['John', 'Harry', 'Jesse', 'John', 'Larry']

c)

['John', 'Harry', 'John', 'Marry', 'Larry']

d)

Error