Practice high-yield Programming & Software Development MCQs on Strings In Python — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: string = "Python" print(string[1:4])
Correct Answer: Option A — yth
Detailed Academic Explanation:
Understanding String Slicing in Python In Python, strings are sequences of characters. We can access parts of a string using slicing . String slicing uses square brackets `[]` and a colon `:` to specify a range of characters. The format is `string[start:end]`. The `start` index indicates where to begin (inclusive), and the `end` index indicates where to stop (exclusive). Let's break down the code: string = "Python" This line assigns the string "Python" to the variable string . print(string[1:4]) This line uses slicing to extract a portion of the string. Let's analyze the indices: - 1 (start index): This means we start at the second character (remember, Python uses zero-based indexing, so the first character is at index 0). - 4 (end index): This means we stop just before the fourth character. Therefore, string[1:4] will extract characters from index 1 ( 'y' ) up to, but not including, index 4. The Result: The characters extracted are "yth". Therefore, the correct answer is Option A: yth
💡Key Conceptual Anchor:Strings In Python
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is the correct way to create a string in Python?
Correct Answer: Option B — 'Hello, World!'
Detailed Academic Explanation:
'Hello, World!' is the correct answer to “Which of the following is the correct way to create a string in Python”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: word = "Python" print(word[2])
Correct Answer: Option A — t
Detailed Academic Explanation:
t is the correct answer to “What is the output of the following code: word = "Python" print(word[2])”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the len() function do when applied to a string?
Correct Answer: Option A — Returns the length of the string
Detailed Academic Explanation:
Returns the length of the string is the correct answer to “What does the len() function do when applied to a string”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which character is used to access individual elements of a string by index in Python?
Correct Answer: Option D — [ and ] (square brackets)
Detailed Academic Explanation:
[ and ] (square brackets) is the correct answer to “Which character is used to access individual elements of a string by index in Python”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following methods is used to find the index of the first occurrence of a substring in a string?
Correct Answer: Option B — find()
Detailed Academic Explanation:
find() is the correct answer to “Which of the following methods is used to find the index of the first occurrence of a substring in a string”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the code: string = "Python" print(string[-2])
Correct Answer: Option A — o
Detailed Academic Explanation:
o is the correct answer to “What is the output of the code: string = "Python" print(string[-2])”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Python, which escape sequence is used to represent a newline character?
Correct Answer: Option A — \n
Detailed Academic Explanation:
\n is the correct answer to “In Python, which escape sequence is used to represent a newline character”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What method is used to convert a string to uppercase in Python?
Correct Answer: Option A — upper()
Detailed Academic Explanation:
upper() is the correct answer to “What method is used to convert a string to uppercase in Python”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method is used to replace a substring in a string with another substring?
Correct Answer: Option A — replace()
Detailed Academic Explanation:
replace() is the correct answer to “Which method is used to replace a substring in a string with another substring”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Python, how can you check if a string starts with a specific substring?
Correct Answer: Option A — startswith()
Detailed Academic Explanation:
startswith() is the correct answer to “In Python, how can you check if a string starts with a specific substring”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method is used to count the occurrences of a substring in a string?
Correct Answer: Option A — count()
Detailed Academic Explanation:
count() is the correct answer to “Which method is used to count the occurrences of a substring in a string”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the strip() method for strings?
Correct Answer: Option A — Removes leading and trailing whitespace
Detailed Academic Explanation:
Removes leading and trailing whitespace is the correct answer to “What is the purpose of the strip() method for strings”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: string = "Python" print(string[::-1])
Correct Answer: Option A — nohtyP
Detailed Academic Explanation:
nohtyP is the correct answer to “What is the output of the following code: string = "Python" print(string[::-1])”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Python, which escape sequence is used to represent a tab character?
Correct Answer: Option D — \s
Detailed Academic Explanation:
\s is the correct answer to “In Python, which escape sequence is used to represent a tab character”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the isalpha() method of a string object check for?
Correct Answer: Option C — Checks if the string is in uppercase
Detailed Academic Explanation:
Checks if the string is in uppercase is the correct answer to “What does the isalpha() method of a string object check for”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method is used to split a string into a list of substrings based on a specified separator?
Correct Answer: Option A — split()
Detailed Academic Explanation:
split() is the correct answer to “Which method is used to split a string into a list of substrings based on a specified separator”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the find() method for strings?
Correct Answer: Option B — Replaces a substring with another
Detailed Academic Explanation:
Replaces a substring with another is the correct answer to “What is the purpose of the find() method for strings”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: string = "Python is fun" print(string.split())
Correct Answer: Option B — Python is fun
Detailed Academic Explanation:
Python is fun is the correct answer to “What is the output of the following code: string = "Python is fun" print(string.split())”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Python, how can you check if a string ends with a specific substring?
Correct Answer: Option D — finish_with()
Detailed Academic Explanation:
finish_with() is the correct answer to “In Python, how can you check if a string ends with a specific substring”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the join() method for strings?
Correct Answer: Option C — Removes whitespace
Detailed Academic Explanation:
Removes whitespace is the correct answer to “What is the purpose of the join() method for strings”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: string = "Python" print(string.find("th"))
Correct Answer: Option D — 4
Detailed Academic Explanation:
4 is the correct answer to “What is the output of the following code: string = "Python" print(string.find("th"))”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method is used to remove leading and trailing whitespace from a string?
Correct Answer: Option C — whitespace()
Detailed Academic Explanation:
whitespace() is the correct answer to “Which method is used to remove leading and trailing whitespace from a string”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: string = "Hello, world!" print(string.replace("o", "i"))
Correct Answer: Option C — Hii
Detailed Academic Explanation:
Hii is the correct answer to “What will be the output of the following code: string = "Hello, world!" print(string.replace("o", "i"))”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the title() method for strings?
Correct Answer: Option D — Removes leading whitespace
Detailed Academic Explanation:
Removes leading whitespace is the correct answer to “What is the purpose of the title() method for strings”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Python, how can you check if a string contains only numeric characters?
Correct Answer: Option B — isnumber()
Detailed Academic Explanation:
isnumber() is the correct answer to “In Python, how can you check if a string contains only numeric characters”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code snippet? print('a@ 1,'.islower())
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “What will be the output of the following Python code snippet? print('a@ 1,'.islower())”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? print("xyyzxyzxzxyy".count('xyy', 2, 11))
Correct Answer: Option B — 0
Detailed Academic Explanation:
0 is the correct answer to “What will be the output of the following Python code? print("xyyzxyzxzxyy".count('xyy', 2, 11))”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? >>>example = "helle" >>>example.find("e")
Correct Answer: Option C — 1
Detailed Academic Explanation:
1 is the correct answer to “What will be the output of the following Python code? >>>example = "helle" >>>example.find("e")”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code snippet? print('xyyxyyxyxyxxy'.replace('xy', '12', 100))
Correct Answer: Option B — 12y12y1212x12
Detailed Academic Explanation:
12y12y1212x12 is the correct answer to “What will be the output of the following Python code snippet? print('xyyxyyxyxyxxy'.replace('xy', '12', 100))”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code snippet? print('abcd'.translate({'a': '1', 'b': '2', 'c': '3', 'd': '4'}))
Correct Answer: Option A — abcd
Detailed Academic Explanation:
abcd is the correct answer to “What will be the output of the following Python code snippet? print('abcd'.translate({'a': '1', 'b': '2', 'c': '3', 'd': '4'}))”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? print('1Rn@'.lower())
Correct Answer: Option B — 1rn@
Detailed Academic Explanation:
1rn@ is the correct answer to “What will be the output of the following Python code? print('1Rn@'.lower())”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code snippet? print('1@ a'.isprintable())
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “What will be the output of the following Python code snippet? print('1@ a'.isprintable())”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What arithmetic operators cannot be used with strings?
Correct Answer: Option C — -
Detailed Academic Explanation:
- is the correct answer to “What arithmetic operators cannot be used with strings”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python statement? >>>chr(ord('A'))
Correct Answer: Option A — A
Detailed Academic Explanation:
A is the correct answer to “What will be the output of the following Python statement? >>>chr(ord('A'))”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code snippet? print('1.1'.isnumeric())
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “What will be the output of the following Python code snippet? print('1.1'.isnumeric())”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? print('*', "abcdef".center(7), '*')
Correct Answer: Option B — *abcdef *
Detailed Academic Explanation:
*abcdef * is the correct answer to “What will be the output of the following Python code? print('*', "abcdef".center(7), '*')”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? print("xyyzxyzxzxyy".endswith("xyy", 0, 2))
Correct Answer: Option D — False
Detailed Academic Explanation:
False is the correct answer to “What will be the output of the following Python code? print("xyyzxyzxzxyy".endswith("xyy", 0, 2))”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code snippet? print(''.isdigit())
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “What will be the output of the following Python code snippet? print(''.isdigit())”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Python code? print('ab'.isalpha())
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “What will be the output of the following Python code? print('ab'.isalpha())”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.