wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

G10 CS String Manipulation

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Python Program

If string_name=‘Programming techniques’.

What is the output of

print(string_name.length) ?

a)

20

b)

21

c)

22

d)

23

e)

0

2.

Python Program

If string_name=‘Programming techniques’.

What is the output of

print(string_name.substring(5,6)) ?

a)

amming

b)

ramming

c)

rammin

d)

gramm

e)

None

3.

Python Program

If string_name=‘Programming techniques’.

What is the output of

print(string_name.substring(5,6)) ?

a)

gramming

b)

ramming

c)

rammin

d)

gramm

e)

None

4.

Python Program

If string_name=‘Programming techniques’.

What is the output of

print(string_name.substring(12,4)) ?

a)

tech

b)

tec

c)

echn

d)

techn

e)

None

5.

Python Program

If string_name=‘Programming techniques’.

What is the output of

print(string_name.substring(12,6)) ?

a)

techin

b)

tec

c)

echn

d)

techn

e)

None

6.

Which of the following represents the code that changes a variable string_name to uppercase characters?

a)

string.upper()

b)

string_name.upper()

c)

string_name.uppercase()

d)

None of the choices

7.

What command is used to find the length in Python program?

a)

lenght( )

b)

len( )

c)

lengthof( )

d)

None of the above

8.

If string_name=‘Patrick’, what is the value returned for string_name[2:3]?

a)

tri

b)

Pat

c)

2 and 3

d)

ric

9.

If string_name=‘Patrick’, what is the value returned for string_name[3:6]?

a)

'trick'

b)

'rick'

c)

'ric'

d)

Error Message

10.

Check either the question and statement makes sense.

If string_name=‘I like Programming’,

what is the output for

print(‘like’ in string_name)?

a)

[2:6]

b)

True

c)

False

d)

None of the above

11.

Check either the question and statement makes sense.

If str1=‘Yes’ and str2=‘No’,

what is the result for str1+str2 in Python?

a)

'YesNo'

b)

'Yes No'

c)

YesNo

d)

Yes and No

12.

What function converts a character to its ASCII code in Python ?

a)

ASC( )

b)

ord( )

c)

chr( )

d)

ascii( )

13.

What function converts a ASCII code to its character in Python ?

a)

ASC( )

b)

ord( )

c)

chr( )

d)

ascii( )

14.

Which of the following method is used to convert the number 9.11 to string in Python

a)

str( )

b)

string( )

c)

int( )

d)

float ( )

15.

Which of the following function is used to convert a string value '4.25' to a datatype such that it can be used in mathematical operations in Python.

a)

str( )

b)

string( )

c)

int( )

d)

float ( )