wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Unit 7 quiz on strings AP CSP

Total questions: 14

Worksheet time: 10mins

Name
Class
Date
1.

What is the output from this code?

a)

ell

b)

llo

c)

ello,

d)

Hello

2.

What is the output from this code?

a)

, W

b)

Wor

c)

orl

d)

lro

3.

What will be the output of the “hello” +1+2+3?

a)

hello123

b)

hello

c)

Error

d)

hello6

4.

which of the following is incorrect?

a)

String is immutable.

b)

Strings are stored in a list when we save them.

c)

lower() function in string is used to return a string by converting the whole given string into lowercase.

d)

str.pop(), will remove the last value of the string called, str

5.

For string symbol + means........................

a)

addition

b)

swapp

c)

concatenation

d)

multiplication

6.

str1='101'

x=int(str1)

z=x+400

print(z)

a)

101400

b)

x400

c)

501

d)

none of above

7.

fruit1="kiwi"

fruit2="strawberry"

print(len(fruit1))

print(len(fruit2))

a)

kiwi and strawberry

b)

4

10

c)

4 10

d)

410

8.

Slicing string

x="BOnvoyage

print(x[4: ])

a)

BOnvo

b)

bonvo

c)

oyage

d)

VOYAGE

9.

Select the characters that can be found in a String

a)

Letters

b)

Numbers

c)

Symbols

10.

What does the following code return?

str = 'Python'

print(str[1:4])

a)

Pyt

b)

yth

c)

tho

d)

ytho

11.

What is printed by the following statement?

print("A" in "APCSP")

a)

Prints True

b)

Prints False

c)

Prints, 0 for index where it is found

12.

What will the output be from the following code?

print("3+4")

a)

7

b)

34

c)

3+4

d)

SyntaxError

13.

Fill in the blank to check if 2 consecutive letters are the same:

for i in range(len(str)):

if ________:

print("same")

a)

str(i)==str(i+1)

b)

str[i]==str[i+1]

c)

str[i] ==str[i:i+1]

d)

str[i]==str[i:i+2]

14.

Mathematical operations can be performed on a string

a)

True

b)

False