Multiple Choice Question For String Manipulation Class 11 Computer Science (CS)



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) lent ()

(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 return the always 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 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) Wah Bhyi aha

(c) WahBhyiWah

(d) WahBhyiWaha

16. Select the correct output of the following String operations.

str = "my name is Anu John"

print (str.capitalize())

(a) ‘My name is anu john’

(b) TypeError: unsupported operand type(s) for * : "str' and 'int'

(c) ‘My name is Anu John'

(d) 'My Name Is Anu John'

17. Choose the correct function to get the character from ASCII number.

(a) ascii(number)

(b) char(number)

(c) chr(number).

(d) all of these

18 s = ’ ’ (single space). Then s.isalnum( ) will return.

(a) True

(b) False

(c) Error

(d) nothing

19 Which of the following functions removes all leading and trailing spaces from a string?

(a) Istrip()

(b) rstrip()

(c) strip()

(d) all of these

20. Which of the following functions will raise an error if the given substring is not found in the string?

(a) find()

(b) index()

(c) replace()

(d) all of thes

3 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post