MCQ on Python String Class 11
Q1. Following is an example of ___________________
sv = “csiplearninghub.com”
a. List
b. String
c. Dictionary
d. None of the above
Q2. Python considered the character enclosed in triple quotes as String.(T/F)
a. True
b. False
Q3. Write the output of the following.
a = "Blog" a ='a' print(a)
a. Bloga
b. aBlog
c. Blog
d. a
Q4. Write the output of the following:
a="We\nto my \nb\t ok" print(a)
a. We to my b ok
b. We to myb ok
c. Weto my b ok
d. None of the above
Q5. Write the output of the following code :
a= "Welcome to \"my\" blog" print(a)
a. Welcome to “my” blog
b. Welcome to \”my\” blog
c. Error
d. None of the above
Q6. Write the output of the following code :
a= "Welcome to \ blog" print(a)
a. Welcome to blog
b. Welcome to \ blog
c. Welcome to blog
d. Error
Q7. Write the output of the following code :
str = "Welcome" str[2] = 'a' print(str)
a. Weacome
b. Error
c. aWelcome
d. Welcomea
Q8. Write the output of the following code :
str = "Welcome" l=len(str) print(l)
a. 6
b. 7
c. 8
d. Error
Q9. What we call the following:
\n \t
a. Escape Sequence
b. Special Character
c. Don’t have any common term
d. Keyword
Q10. Write the output of the following code :
a = '''A B C''' print(a)
a. ABC
b. A BC
c. A B C
d. Error
MCQ on Python String Class 11
Click here to check your performance in Python String Class 11
MCQ on Python String Class 11
Q11. What is the index value of ‘i’ in string “Learning”
a. 5
b. 3
c. 6
d. 7
Q12. Index value in String should be of type ________________
a. Float
b. Integer
c. String
d. Boolean
Q13. What type of error is returned by the following :
str = "Learning" print(str[10])
a. Error in Index
b. Index out of range in string
c. IndexError
d. None of the above
Q14. Which character will have same index value when you access elements from the beginning and from the end(ignore the negative sign) in the following string.
s = “Welcome to my blog”
a. ‘t’
b. ‘ ‘
c. ‘o’
d. ‘t’
Q15. String traversal can be done using ‘for’ loop only.(T/F)
a. True
b. False
Q16. Which of the following statement is correct in accessing each element of string?
a) a="Learning" while(i): print(i) b) a="Learning" for i in a: print(i)
a. a only
b. b only
c. both a and b
d. None of the above
Q17. Name the function which is used to find length of string.
a. length( )
b. len( )
c. strlen( )
d. slen( )
Q18. Write the output of the following code :
for i in "STR": print(i)
a. S TR
b. STR
c. S T R
d. S T R
Q19. Write the output of the following code :
a="Learn" while(a): print(a)
a. L e a r n
b. Error
c. Infinite Loop
d. Learn
Q20. Which operator is used with integers as well as with strings?
a. /
b. //
c. **
d. *
MCQ on Python String Class 11
Click here to check your performance in Python String Class 11
MCQ on Python String Class 11
Q21. Write the output of the following:
2 + '3'
a. 2 3
b. 23
c. SyntaxError
d. TypeError
Q22. Which operator is used for string concatenation?
a. *
b. //
c. +
d. –
Q23. Write the output of the following code :
for i in (1,2,3): print("@" * i)
a. Error
b. @@@@@@
c. @ @@ @@@
d. @ @ @ @ @ @
Q24. How many operators are used in the following statement?
7 + 4 * 8 // 2 ** 2 - 6 / 1
a. 5
b. 6
c. 7
d. 8
Q25. Write the output of the following code :
s="blog" for i in range(-1,-len(s),-1): print(s[i],end="$")
a. g$o$l$b$
b. g$o$l$
c. Error
d. None of the above
Q26. Write the output of the following code :
s= "str" s1 = "string" print(s1 in s)
a. True
b. False
c. Error
d. None of the above
Q27. Write the output of the following code :
print("Amita" > "amit")
a. True
b. False
c. Error
d. None of the above
Q28. What is the ASCII value of “A”?
a. 97
b. 66
c. 65
d. 96
Q29. Write the output of the following code :
print("Str"[1:2])
a. t
b. No Output
c. Error
d. None of the above
Q30. Write the output of the following code :
for i in range(65,70): print(chr(i))
a. Error
b. TypeError
c. A B C D E
d. ABCDE
MCQ on Python String Class 11
Click here to check your performance in Python String Class 11
MCQ on Python String Class 11
Q31. Write the output of the following:
print(“A#B#C#D#E”.split(“#”,2))
a. [‘A’, ‘B’, ‘C#D#E’]
b. [‘A#’, ‘B#’, ‘C#D#E’]
c. [‘A’, ‘B’, ‘C’ , ‘D’ , ‘E’]
d. Error
Q32. Write the output of the following:
print(“A#B#C#D#E”.replace(“#”,”?”))
a. A#B#C#D#E
b. A?B?C?D?E
c. Can not replace as Strings are immutable
d. Error
Q33. Write the output of the following:
print(“I love my Country”.find(“o”,4))
a. 3
b. 12
c. 11
d. 3,11
Q34. Write the output of the following.
print(‘#’.join(“12345”))
a. #12345
b. #12345#
c. 1#2#3#4#5
d. 1#2#3#4#5#
Q35. Which of the following is not a String built in functions?
a. isupper( )
b. lower( )
c. partition( )
d. swapcases( )
Q36. Write the output of the following:
for i in range(91,100): if chr(i)=='a': pass else: print(i)
a. 91 92 93 94 95 96 97 98 99
b. 91 92 93 94 95 96 98 99
c. 91 92 93 94 95 96
d. Error
Q37. Write the output of the following:
print(len("\\\\\\///"))
a. 9
b. Error
c. 3
d. 6
Q38. Which of the following function returns the ASCII/Unicode value character?
a. asc( )
b. ord( )
c. asci( )
d. ascii( )
Q39. Which of the following statements will also return the same result as given statement?
print(“Computer” + “Computer”)
a. print(“Computer” , ” “, “Computer”)
b. print(“Computer”,”Computer”)
c. print(“Computer” **2)
d. print(“Computer” * 2)
Q40. Write the output of the following:
for i in range(len("python"),12,2): print("python"[i-6])
a. p t o
b. p y t h o n
c. y h n
d. p y t h
MCQ on Python String Class 11
Click here to check your performance in Python String Class 11
MCQ on Python String Class 11
Q41. Which of the following is a mapping data type?
a. String
b. List
c. Tuple
d. Dictionary
Q42. A _____________ can be created by enclosing one or more characters in single, double or triple quote.
a. String
b. List
c. Tuple
d. Dictionary
Q43. Characters in a string can be _________ enclosed in quotes.
a. Digits
b. white space
c. letter
d. All of the above
Q44. Each individual character in a string can be accessed using a technique called ____________
a. Indexing
b. Replication
c. Concatenation
d. None of the above
Q45. If we give index value out of the range then we get an ___
a. ValueError
b. SyntaxError
c. IndexError
d. Error
Q46. The index of the first character ____________ on the string is 0
a. from left
b. from right
c. from middle
d. none of the above
Q47. What type of error is returned by statement :
>>> str[1.5]
a. SyntaxError
b. ValueError
c. IndexError
d. TypeError
Q48. Write the output of the following.
str = “python”
print(str[2+1])
a. t
b. h
c. th
d. Error
Q49. Content of string can not be changed, it means that string is
a. mutable
b. immutable
c. reversible
d. none of the above
Q50. What type of error is returned by following code:
>>> str1 = “Hello World!”
>>> str1[1] = ‘a’
a. TypeError
b. SyntaxError
c. ValueError
d. NoError
MCQ on Python String Class 11
Click here to check your performance in Python String Class 11
MCQ on Python String Class 11
Q51. Python allows _____________ operations on string data type.
a. Concatenation
b. Membership
c. Slicing
d. All of the above
Q52. Write the output of the following.
>>> str1 = ‘Hello World!’
>>> ‘W’ in str1
a. True
b. False
c. No
d. None of the above
Q53. _____________ method is used to access some part of a string or substring.
a. Slicer
b. Slicing
c. Membership
d. None of the above
Q54. str1[n:m] returns all the characters starting from str1[n] till str1[m-1].(T/F)
a. True
b. False
Q55. str[5 : 11] will return ___________ characters.
a. 5
b. 6
c. 11
d. None of the above
Q56. str[11 : 5] will return ____________
a. empty string
b. complete string
c. string of six characters
d. None of the above
Q57. str[ : ] will return _______________
a. empty string
b. Complete String
c. Partial String
d. Error
Q58. Slice operation can also take a third parameter that specifies the ________
a. Starting index
b. Ending index
c. Step Size
d. None of the above
Q59. Which of the following is correct slicing operation to extract every kth character from the string str1 starting from n and ending at m-1.
a. str1[: : k]
b. str1[n : m+1 : k]
c. str1[n : m : k ]
d. str1[m : n : k ]
Q60. Which of the following will return reverse string str1?
a. str1[ : : -1]
b. str1[: : 1]
c. str1[: -1 : -1 ]
d. None of the above
MCQ on Python String Class 11
Click here to check your performance in Python String Class 11
MCQ on Python String Class 11
Q61 We can access each character of a string or traverse a string using _______________
a. for loop only
b. while loop only
c. both of the above
d. conditional statement
Q62. Which of the following function returns the string with first letter of every word in the string in uppercase and rest in lowercase?
a. swapcase( )
b. upper( )
c. title( )
d. capitalize( )
Q63. Write the output of the following:
s = ” Hello”
print(s.find(‘a’))
a. 0
b. -1
c. 1
d. Error
Q64. What index value is returned by the following code?
s = “Hello”
print(s.find(‘l’))
a. 2
b. 3
c. 4
d. -2
Q65. Following code will return ?
s = “Hello”
print(s.count(‘l’,2,5))
a. 2
b. 3
c. 1
d. none of the above
Q66. Name a function which is same as find() but raises an exception if the substring is not present in the given string.
a. index( )
b. endswith( )
c. startswith( )
d. count( )
Q67. Write the output of the following.
>>> str1 = ‘Hello World! Hello
>>> str1.index(‘Hee’)
a. 0
b. -1
c. Error
d. None of the above
Q68. Write the output of the following.
>>> str1 = ‘Hello World!’
>>> str1.endswith(‘World!’)
a. True
b. False
c. Yes
d. Error
Q69. Write the output of the following.
s = “hello 123”
print(s.islower())
a. False
b. True
c. Error
d. None of the above
Q70. Write the output of the following :
>>> str1 = ‘HelloWorld!!’
>>> str1.isalnum()
a. False
b. True
c. Error
d. None of the above
MCQ on Python String Class 11
Click here to check your performance in Python String Class 11
MCQ on Python String Class 11
Q71. Write the output of the following:
>>> str1 = 'hello WORLD!'
>>> str1.title()
a. HELLO world
b. Hello World
c. Hello world
d. HeLlO WoRlD
Q72. Write the output of the following :
>>> str1 = 'Hello World! Hello Hello'
>>> str1.count('Hello',12,25)
a. 1
b. 2
c. 3
d. 4
Q73. Write the output of the following :
>>> str1 = 'Hello World! Hello Hello'
>>> str1.count('Hello')
a. 1
b. 2
c. 3
d. 4
Q74. Write the output of the following :
print("Absbcbcgdbc".count("b",4))
a. 1
b. 2
c. 3
d. 4
Q75. Write the output of the following :
print("Absbcbcgdbc".find("b",5))
a. 1
b. 2
c. 5
d. 6
Q76. Which of the following function returns the index value of first occurrence of substring occurring in the given string.
a. index( )
b. find( )
c. Both of the above
d. None of the above
Q77. find( ) function returns ___________ if the substring is not present in the given string
a. 0
b. 1
c. -1
d. Error
Q78. index( ) function returns _______________ if the substring is not present in the given string
a. 0
b. 1
c. -1
d. Error
Q79. >>> “Hey!”.endswith(‘!’) will return _____________________
a. True
b. False
c. Error
d. None of the above
Q80. Which of the function returns Boolean value?
a. find( )
b. index( )
c. endwith( )
d. endswith( )
MCQ on Python String Class 11
Click here to check your performance in Python String Class 11
MCQ on Python String Class 11
Q81. Write the output of the following:
>>> str1 = 'String MCQ'
>>> str1.startswith('Str')
a. True
b. False
c. Yes
d. No
Q82. Write the output of the following:
print("Welcome-Python".isalnum())
a. True
b. False
c. Yes
d. No
Q83. Write the output of the following:
print(str("WelcomePython".isalnum()).upper())
a. TRUE
b. True
c. FALSE
d. Error
Q84. Write the output of the following:
>>> str1 = 'hello ??' >>> str1.islower( )
a. No
b. True
c. False
d. Error
Q85. Which of the following function returns True if the string is non-empty and has all uppercase alphabets.
a. islower( )
b. isupper( )
c. Islower( )
d. istitle
Q86. Write the output of the following:
>>> str1 = 'Hello World!' >>> str1.replace('o' , '*')
a. ‘Hello World!’
b. ‘Hell* W*rld!’
c. ‘Hello W*rld!’
d. Error
Q87. Write the output of the following:
>>> str1 = 'India is a Great is Country'
>>> str1.partition('is')
a. (‘India ‘, ‘is’, ‘ a Great is Country’)
b. (‘India ‘, ‘is’, ‘a Great’, ‘is’, ‘Country’)
c. (‘India ‘, ‘is’, ‘ a Great Country’)
d. Error
Q88. Write the output of the following:
str = "Amit is a is a"
s = str.partition('is')
print(s[1])
a. is a
b. a
c. is
d. i
Q89. partition( ) function of string in python return the result in the form of _________________
a. String
b. List
c. Tuple
d. Dictionary
Q90. partition() function divides the main string into ________ substring.
a. 1
b. 2
c. 3
d. 4
MCQ on Python String Class 11
Click here to check your performance in Python String Class 11
MCQ on Python String Class 11
Q91. split( ) function returns the _______________of words delimited by the specified substring.
a. List
b. Tuple
c. Dictionary
d. None of the above
Q92. If no delimiter is given in split( ) function then words are separated by ____________
a. space
b. colon
c. semi colon
d. None of the above
Q93. Write the output of the following:
"python".join("@")
a. ‘p@y@t@h@o@n’
b. ‘p@y@t@h@o@n@’
c. ‘@p@y@t@h@o@n@’
d. ‘@’
Q94. Write the output of the following:
"@".join("python")
a. ‘p@y@t@h@o@n’
b. ‘p@y@t@h@o@n@’
c. ‘@p@y@t@h@o@n@’
d. ‘@’
Q95. Write the output of the following:
>>> len(" python".lstrip()) #2 spaces are given before "python"
a. 5
b. 6
c. 7
d. 8
Q96. Which of the following function removes only leading spaces from the string?
a. strip( )
b. lstrip( )
c. rstrip( )
d. Lstrip( )
Q97. Which of the following function can take maximum three arguments/parameters?
a. find( )
b. index( )
c. count( )
d. All of the above
Q98. Which of the following function return the integer value?
a. lower( )
b. upper( )
c. islower( )
d. find( )
Q99. Which of the following is not an inbuilt function of string?
a. length( )
b. find( )
c. endswith( )
d. split( )
Q100. Which function in the following statement will execute first?
print("amit".lower().upper())
a. print( )
b. lower( )
c. upper( )
d. None of the above
MCQ on Python String Class 11
Click here to check your performance in Python String Class 11
MCQ on Python String Class 11
Q101. Which function in the following statement will execute last?
print("amit".lower().upper())
a. print( )
b. lower( )
c. upper( )
d. None of the above
Q102. Write the output of the following:
print('aisabisacisadisae'.split('isa',3))
a. [‘a’, ‘b’, ‘c’, ‘disae’]
b. [‘a’, ‘b’, ‘cisadisae’]
c. [‘a’, ‘b’, ‘c’, ‘d’, ‘e’]
d. None of the above
Q103. Write the output of the following:
print('aisabisacisadisae'.split('isa'))
a. [‘a’, ‘b’, ‘c’, ‘disae’]
b. [‘a’, ‘b’, ‘cisadisae’]
c. [‘a’, ‘b’, ‘c’, ‘d’, ‘e’]
d. None of the above
Q104. print(“aNd&*”.swapcase()) will display ________________
a. AnD*&
b. AnD&*
c. aNd&*
d. Error
Q105. Write the output of the following:
print('hash-tag'.title())
a. HashTag
b. Hash-tag
c. Hash-Tag
d. Error
MCQ on Python String Class 11
Q106. Fill in the blank given below to get output – “amit is a g@@d boy”
print('amit is a good boy'.replace('o', '@', _________ ))
a. 0
b. 1
c. 2
d. Nothing
Q107. print(‘Welcome TO My Blog’.istitle()) will display ________________
a. True
b. False
c. Error
d. None of the above
Q108. print(‘Welcome TO My Blog'[2:6]) will display __________
a. lcom
b. lcome
c. lco
d. None of the above
Q109. print(‘Welcome TO My Blog'[2:6] + ‘Welcome TO My Blog'[5:9]) will display ___
a. lcomme T
b. lcomme
c. lcomme To
d. None of the above
Q110. print(“WZ-1,New Ganga Nagar,New Delhi”.rfind(‘New’)) will display _____
a. 21
b. 5
c. 22
d. 4
MCQ on Python String Class 11
Click here to check your performance in Python String Class 11
MCQ on Python String Class 11
Q111. Which of the following statement will return error?
a. print(“Hello” + “Bye”)
b. print(“Hello” + “123”)
c. print(“Hello” + 123)
d. print(“456” + “123”)
Q112. print(ord(“A”)) will return ___
a. integer value
b. string value
c. list
d. tuple
Q113. Write the output of the following:
s="str" for i in s: Â Â Â if i.islower(): Â Â Â Â Â Â print(s.swapcase()
a. S T R
b. STR
c. STR STR STR
d. None of the above
Q114. Write the output of the following:
s="str" for i in range(len(s)): s=s.upper() print(s.upper() + str(s.islower()))
a. STRFalse STRFalse STRFalse
b. STRFalse STRFalse
c. STRTrue STRTrue STRTrue
d. Error
Q115. Select the wrong option in reference to the statement given below:
(operand1) * (operand2) = No error
a. Both operands can be of type integer
b. operand1 can be of type integer and operand2 can be of type string
c. operand1 can be of type string and operand2 can be of type integer
d. Both operands can be of type string
Q116. print(“a” in “amit”) will return _________________
a. Integer value
b. String value
c. Boolean value
d. None of the above
Q117. >>>chr(97) will return ________________
a. A
b. a
c. B
d. b
Q118. Write the output of the following:
>>> s = "i love my country"
>>> r = "i love my class"
>>> s[2:5] + s[-7:]
a. ‘lovcountry’
b. ‘lovecountr’
c. ‘lovcountry m’
d. ‘i lovcountr’
Q119. >>> max(“my name is”) will display ____
a. a
b. name
c. y
d. is
Q120. “max”[: : -1].startswith(“x”) will display _________
a. x
b. m
c. True
d. False
MCQ on Python String Class 11
Click here to check your performance in Python String Class 11
MCQ on Python String Class 11
Q121. In python “a” is an example of _______________________
a. String data type
b. Character data type
c. Integer data type
d. None of the above
Q122. Concatenation of string means _________________
a. Joining of strings
b. Splitting of strings
c. Slicing of strings
d. Repetition of strings
Q123. Read the statements given below and identify the right option
Statement A : >>>str1[6] gives sixth character of the string “str1”.
Statement B : string indices must be of type integers.
a. Statement A is correct.
b. Statement B is correct.
c. Statement A is correct, but Statement B is incorrect.
d. Statement A is incorrect, but Statement B is correct.
Q124. Read the statements given below and identify the right option
Statement A : Python allows an index value to be negative also.
Statement B : Negative indices are used when we want to access the characters of the string from left to right.
a. Statement A is correct.
b. Statement B is correct.
c. Statement A is correct, but Statement B is incorrect.
d. Statement A is incorrect, but Statement B is correct.
Q125. Read the statements given below and identify the right option
Statement A : A string is an immutable data type.
Statement B : Contents of the string cannot be changed after it has been created.
a. Statement A is correct.
b. Statement B is correct.
c. Statement A is correct, and Statement B is also correct.
d. Statement A is incorrect, but Statement B is correct.
MCQ on Python String Class 11
Q126. Read the statements given below and identify the right option
Statement A : Python has two membership operators ‘in’ and ‘not in’
Statement B : The ‘in’ operator takes two strings and returns False if the first string appears as a substring in the second string, otherwise it returns True .
a. Statement A is correct.
b. Statement B is correct.
c. Statement A is correct, but Statement B is incorrect.
d. Statement A is incorrect, but Statement B is correct.
Q127. Read the statements given below and identify the right option
Statement A : count( ) function returns the first occurrence of index of substring str occurring in the given string.
Statement B : lower( ) function converts the upper case letters to lower case .
a. Statement A is correct.
b. Statement B is correct.
c. Statement A is correct, but Statement B is incorrect.
d. Statement A is incorrect, but Statement B is correct.
MCQ on Python String Class 11
Disclaimer : I tried to give you the correct solution of “ MCQ on Python String Class 11 ” , but if you feel that there is/are mistakes in “ MCQ on Python String Class 11 ” given above, you can directly contact me at csiplearninghub@gmail.com. NCERT Book and Study material available on CBSE official website are used as a reference to create above “ MCQ on Python String Class 11 ”
MCQ on Python String Class 11
Important Links
100 Practice Questions on Python Fundamentals
120+ MySQL Practice Questions
90+ Practice Questions on List
50+ Output based Practice Questions
100 Practice Questions on String
70 Practice Questions on Loops
120 Practice Questions of Computer Network in Python
70 Practice Questions on if-else
40 Practice Questions on Data Structure
Computer Science Syllabus 2021-2022.
Informatics Practices Syllabus 2021-2022
Class 12 Computer Science Chapter wise MCQ