10AI Rev String
10AI Rev String
2EZ.IN
A) HELLO
B) hello
C) HeLLo
D) hellO
7. In Python, what does str.strip() do?
A) Removes all whitespace from the string
B) Removes leading and trailing whitespaces
C) Converts the string to lowercase
D) Replaces spaces with underscores
8. How do you check if a string starts with a certain substring
in Python?
A) startswith()
B) endswith()
C) find()
D) index()
9. Which of the following will correctly split a string at every
occurrence of a space character?
A) str.split(",")
B) str.split(" ")
C) str.split("-")
D) str.split()
10. Which method will return True if a string contains only
alphabetic characters?
A) isnumeric()
B) isdigit()
C) isalnum()
D) isalpha()
C) Space
D) Tab
12. What does the capitalize() method do in Python?
A) Converts the entire string to uppercase
B) Converts the first character to uppercase
C) Capitalizes every word in the string
D) Converts the entire string to lowercase
13. How do you check if a string ends with a specific substring
in Python?
A) startswith()
B) endswith()
C) find()
D) index()
14. What will the output of "hello".title() be?
A) hello
B) HELLO
C) Hello
D) hELLO
15. In Python, how do you count the occurrences of a
substring in a string?
A) find()
B) index()
C) count()
D) search()
16. Which method is used to replace a substring with another
substring in Python?
A) sub()
B) replace()
C) switch()
D) substitute()
17. What will the str.isdigit() method return if str = "123abc"?
A) True
B) False
4
2EZ.IN
C) Error
D) None
18. What is the output of the expression "Python".find('t')?
A) 3
B) 2
C) 1
D) 4
19. Which of the following is the correct way to check if a
string consists only of whitespace characters?
A) str.isdigit()
B) str.isspace()
C) str.isalpha()
D) str.isalnum()
20. What will the output of "abcd".index('b') be?
A) 0
B) 1
C) 2
D) 3
C) None
D) Error
24. Which method would you use to concatenate two strings
with a space in between?
A) concatenate()
B) append()
C) join()
D) +
25. Which method in Python checks if all characters in a string
are uppercase?
A) isupper()
B) islower()
C) upper()
D) lower()
26. What is the result of "abcde".count('e')?
A) 1
B) 2
C) 0
D) 4
27. What does "hello".center(10) do in Python?
A) Pads the string with whitespace to make the total length 10
B) Removes spaces from both ends of the string
C) Splits the string into 10 equal parts
D) Returns the middle 10 characters of the string
28. Which method is used to check whether a string contains
only alphanumeric characters?
A) isnumeric()
B) isalnum()
C) isalpha()
D) isdigit()
29. What does "abcd".endswith("cd") return?
A) True
B) False
6
2EZ.IN
C) None
D) Error
30. Which of the following methods reverses a string in
Python?
A) reverse()
B) [::-1]
C) str.reverse()
D) str[::-2]
C) 4
D) 5
36. What does "Hello World".count('o') return?
A) 0
B) 1
C) 2
D) 3
37. What does "HELLO".isupper() return?
A) True
B) False
C) None
D) Error
38. How do you convert an integer into a string in Python?
A) str()
B) int()
C) float()
D) str(int)
39. Which method is used to convert the first character of
each word to uppercase?
A) capitalize()
B) upper()
C) title()
D) lower()
40. What does "apple".startswith('a') return?
A) True
B) False
C) None
D) Error
C) 4
D) 5
42. How can you replace all occurrences of a character in a
string?
A) str.remove()
B) str.replace()
C) str.split()
D) str.join()
43. What will "Hello World".upper() return?
A) HELLO WORLD
B) hello world
C) Hello world
D) hello World
44. Which method converts a string to lowercase?
A) lower()
B) capitalize()
C) upper()
D) strip()
45. What will "123".isdigit() return?
A) True
B) False
C) None
D) Error
46. What is the output of "test".capitalize()?
A) Test
B) TEST
C) test
D) teSt
47. Which method is used to return a string with leading
zeros?
A) strip()
B) ljust()
9
2EZ.IN
C) zfill()
D) rjust()
48. What does "welcome".startswith("wel") return?
A) True
B) False
C) None
D) Error
49. What will be the output of "abcd".find('z')?
A) -1
B) 0
C) None
D) Error
50. What does "Good".islower() return?
A) True
B) False
C) None
D) Error
C) isdigit()
D) isspace()
54. What is the output of "abcd".rindex('b')?
A) 0
B) 1
C) 2
D) 3
55. What does "Hello World".replace("o", "a") return?
A) Hella Warld
B) Hella World
C) Helloo World
D) Hella Waalrd
56. What will "test".endswith('t') return?
A) True
B) False
C) None
D) Error
57. What is the output of "python".islower()?
A) True
B) False
C) None
D) Error
58. Which method removes the trailing characters from a
string?
A) rstrip()
B) lstrip()
C) strip()
D) remove()
59. What does "apple".rindex('p') return?
A) 1
B) 2
C) 0
D) -1
11
2EZ.IN
A) str.reverse()
B) [::-1]
C) reverse()
D) rev()
73. Which of the following returns True if the string is a valid
identifier?
A) isalpha()
B) isalnum()
C) isidentifier()
D) isdigit()
74. What will "apple".find('z') return?
A) -1
B) 1
C) 0
D) None
75. How do you check if a string contains only whitespace
characters?
A) isspace()
B) isalnum()
C) isalpha()
D) isdigit()
76. What will be the result of "hello".ljust(10)?
A) hello
B) hello
C) hellohello
D) hello
77. Which method would you use to pad a string with zeros
on the left?
A) zfill()
B) rjust()
C) ljust()
D) pad()
78. What is the output of "Python".islower()?
14
2EZ.IN
A) True
B) False
C) None
D) Error
79. What will be the result of "hello world".find('l')?
A) 2
B) 3
C) 4
D) None
80. What does "python3".isdigit() return?
A) True
B) False
C) None
D) Error
A) Python
B) PYTHON
C) pYTHON
D) Python Python
85. What will "python".replace('p', 'b') return?
A) bython
B) pythonb
C) bythonp
D) pybhon
86. What does "python".center(10) return?
A) python
B) python
C) python
D) python
87. How do you check if a string contains only digits in
Python?
A) isdigit()
B) isalnum()
C) isnumeric()
D) isalpha()
88. What is the result of "Python".endswith('n')?
A) True
B) False
C) None
D) Error
89. What will "hello world".rindex('o') return?
A) 4
B) 7
C) 5
D) 10
90. What does "Python".zfill(10) return?
A) 0000Python
B) 000Python
16
2EZ.IN
C) Python0000
D) PythonPython
C) title()
D) lower()
97. What will be the result of "python".index('h')?
A) 3
B) 2
C) 4
D) 5
98. What is the output of "apple".find('p')?
A) 0
B) 1
C) 2
D) None
99. What will "abcde".replace('a', 'z') return?
A) zbcde
B) azcde
C) abzde
D) abcze
100. What does "hello".swapcase() return?
A) HELLO
B) hELLO
C) Hello
D) HeLLo
Answers:
1. A
2. A
3. B
4. A
5. B
6. B
7. B
8. A
9. B
18
2EZ.IN
10. D
11. C
12. B
13. B
14. C
15. C
16. B
17. B
18. A
19. B
20. B
21. A
22. A
23. B
24. D
25. A
26. A
27. A
28. B
29. A
30. B
31. C
32. A
33. C
34. A
35. C
36. C
37. A
38. A
39. C
40. A
41. B
42. B
19
2EZ.IN
43. A
44. A
45. A
46. A
47. C
48. A
49. A
50. B
51. B
52. A
53. B
54. B
55. A
56. A
57. A
58. A
59. B
60. B
61. A
62. A
63. A
64. D
65. A
66. A
67. A
68. A
69. B
70. A
71. C
72. B
73. C
74. A
75. A
20
2EZ.IN
76. A
77. A
78. B
79. C
80. B
81. A
82. A
83. A
84. A
85. A
86. A
87. A
88. A
89. B
90. A
91. B
92. A
93. A
94. A
95. A
96. C
97. A
98. B
99. A
100. B