MAHARISHI VIDYA MANDIR-MOGAPPAIR
CLASS XI -COMPUTER SCIENCE WORKSHEET
TOPIC: STRING
1) Negative index -1 belongs to .......... of string.
a) first character
b) last character
c) second last character
d) second character
2) Which of the following is/are not legal string operators?
a) In
b) +
c) *
d) /
3) Which of the following functions will return the total number of characters in a string?
a) count()
b) index()
c) len()
d) all of these
4) Which of the following functions will return the last three characters of a string s? a) s[3:]
b) s[:3]
c) s[-3:]
d) s[:-3]
5) Which of the following functions will return the first three characters of a string s? a) s[3:]
b) s[:3]
c) s[-3:]
d) s[:-3]
6) Which of the following functions will return the string in all caps? a) upper()
b) toupper()
c) isupper()
d) to-upper()
7) Which of the following functions will return the string with every 'P' replaced with a 'z'?
a) find()
b) index()
c) replace()
d) split()
8) Which of the following functions will return a list containing all words of the string? a)
find()
b) index()
c) partition()
d) split()
9) Which of the following functions will always return a tuple of 3 elements? a) find()
b) index()
c) partition()
d) split()
10) What is the output of the following code?
str1 = "Mission 999"
str2 = "999"
print(str1.isdigit(),str2.isdigit())
a) False True
b) False False
c) True False
d) True True
11 ) Choose the correct function to get the ASCII code of a character.
a) char('char')
b) ord('char')
c) ascii('char')
d) All of these
12)Which method should I use to convert String "Python programming is fun" to "Python
Programming Is Fun" ?
a) capitalize()
b) title()
c) istitle()
d) upper()
13) Guess the correct output of the following String operations.
str1 = 'Wah'
print(str1*2)
a) WahWah
b) TypeError: unsupported operand type(s) for * : 'str' and 'int'
c) WWaahh
d) Wah2
14) What is the output of the following string operation?
str = "My roll no. is 12"
print(str.isalnum())
a) True
b) False
c) Error
d) No output
15 Select the correct output of the following String operations.
str1 = 'Waha'
print(str1[:3] + 'Bhyi' + str1[-3:])
a) Wah Bhyi Wah
b) WahBhyiaha c)
WahBhyiWah d)
WahBhyiWaha