Practice high-yield Programming & Software Development MCQs on Strings In Python — Part 2 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 Python code snippet? print('abcd'.translate('a'.maketrans('abc', 'bcd')))
Correct Answer: Option D — bcdd
Detailed Academic Explanation:
bcdd is the correct answer to “What will be the output of the following Python code snippet? print('abcd'.translate('a'.maketrans('abc', 'bcd')))”. This question is standard in competitive examination syllabi for Strings In Python.
💡Key Conceptual Anchor:Strings In Python
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Suppose i is 5 and j is 4, i + j is same as . . . . . . . .
Correct Answer: Option B — i.__add__(j)
Detailed Academic Explanation:
i.__add__(j) is the correct answer to “Suppose i is 5 and j is 4, i + j is same as . . . . . . . .”. 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 will be the output of the following Python code snippet? print('abcdefcdghcd'.split('cd'))
Correct Answer: Option B — ['ab', 'ef', 'gh', "]
Detailed Academic Explanation:
['ab', 'ef', 'gh', "] is the correct answer to “What will be the output of the following Python code snippet? print('abcdefcdghcd'.split('cd'))”. 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 will be the output of the following Python code? print("ab\tcd\tef".expandtabs('+'))
Correct Answer: Option D — none of the mentioned
Detailed Academic Explanation:
none of the mentioned is the correct answer to “What will be the output of the following Python code? print("ab\tcd\tef".expandtabs('+'))”. 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
What will be the output of the following Python code snippet? print('+99'.zfill(5))
Correct Answer: Option C — +0099
Detailed Academic Explanation:
+0099 is the correct answer to “What will be the output of the following Python code snippet? print('+99'.zfill(5))”. 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
What will be the output of the following Python code? print("abcdef".center(0))
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(0))”. 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 will be the output of the following Python code? print('a'.maketrans('ABC', '123'))
{65: 49, 66: 50, 67: 51} is the correct answer to “What will be the output of the following Python code? print('a'.maketrans('ABC', '123'))”. 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
What will be the output of the following Python code snippet? print('abcdefcdghcd'.split('cd', 0))
Correct Answer: Option A — ['abcdefcdghcd']
Detailed Academic Explanation:
['abcdefcdghcd'] is the correct answer to “What will be the output of the following Python code snippet? print('abcdefcdghcd'.split('cd', 0))”. 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 will be the output of the following Python code? print("Hello {} and {}".format('foo', 'bin'))
Correct Answer: Option A — Hello foo and bin
Detailed Academic Explanation:
Hello foo and bin is the correct answer to “What will be the output of the following Python code? print("Hello {} and {}".format('foo', 'bin'))”. 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
What will be the output of the following Python statement? >>>"abcd"[2:]
Correct Answer: Option C — cd
Detailed Academic Explanation:
cd is the correct answer to “What will be the output of the following Python statement? >>>"abcd"[2:]”. 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
What will be the output of the following Python code? print("Hello {name1} and {name2}".format('foo', 'bin'))
Correct Answer: Option C — Error
Detailed Academic Explanation:
Error is the correct answer to “What will be the output of the following Python code? print("Hello {name1} and {name2}".format('foo', 'bin'))”. 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
What will be the output of the following Python code snippet? print('0xa'.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('0xa'.isdigit())”. 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
The output of executing string.ascii_letters can also be achieved by:
Correct Answer: Option B — string.ascii_lowercase+string.ascii_uppercase
Detailed Academic Explanation:
string.ascii_lowercase+string.ascii_uppercase is the correct answer to “The output of executing string.ascii_letters can also be achieved by:”. 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 will be the output of the following Python code snippet? print('{:,}'.format(1112223334))
Correct Answer: Option A — 1,112,223,334
Detailed Academic Explanation:
1,112,223,334 is the correct answer to “What will be the output of the following Python code snippet? print('{:,}'.format(1112223334))”. 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
What will be the output of the following Python code? print('{0:.2%}'.format(1/3))
Correct Answer: Option C — 33.33%
Detailed Academic Explanation:
33.33% is the correct answer to “What will be the output of the following Python code? print('{0:.2%}'.format(1/3))”. 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 will be the output of the following Python code? print("abcdef".center(7, '1'))
Correct Answer: Option A — 1abcdef
Detailed Academic Explanation:
1abcdef is the correct answer to “What will be the output of the following Python code? print("abcdef".center(7, '1'))”. 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
What will be the output of the following Python code? print('xyxxyyzxxy'.lstrip('xyy'))
Correct Answer: Option A — zxxy
Detailed Academic Explanation:
zxxy is the correct answer to “What will be the output of the following Python code? print('xyxxyyzxxy'.lstrip('xyy'))”. 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
The format function, when applied on a string returns . . . . . . . .
Correct Answer: Option D — str
Detailed Academic Explanation:
str is the correct answer to “The format function, when applied on a string returns . . . . . . . .”. 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 will be the output of the following Python code? print('ab,12'.isalnum())
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “What will be the output of the following Python code? print('ab,12'.isalnum())”. 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
What will be the output of the following Python code? print("xyyzxyzxzxyy".count('yy', 2))
Correct Answer: Option C — 1
Detailed Academic Explanation:
1 is the correct answer to “What will be the output of the following Python code? print("xyyzxyzxzxyy".count('yy', 2))”. 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 will be the output of the following Python code? print("abcdef".find("cd") == "cd" in "abcdef")
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “What will be the output of the following Python code? print("abcdef".find("cd") == "cd" in "abcdef")”. 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 will be the output of the following Python code? print("Hello {0} and {1}".format(('foo', 'bin')))
Correct Answer: Option C — Error
Detailed Academic Explanation:
Error is the correct answer to “What will be the output of the following Python code? print("Hello {0} and {1}".format(('foo', 'bin')))”. 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
What will be the output of the following Python code? print("abcdef".center())
Correct Answer: Option C — error
Detailed Academic Explanation:
error is the correct answer to “What will be the output of the following Python code? print("abcdef".center())”. 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 Python code? >>>example = "snow world" >>>example[3] = 's' >>>print example
Correct Answer: Option C — Error
Detailed Academic Explanation:
Error is the correct answer to “What will be the output of the following Python code? >>>example = "snow world" >>>example[3] = 's' >>>print example”. 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 will be the output of the following Python code snippet? print('\t'.isspace())
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('\t'.isspace())”. 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
What will be the output of the following Python code snippet? print('xyyxyyxyxyxxy'.replace('xy', '12', 0))
Correct Answer: Option A — xyyxyyxyxyxxy
Detailed Academic Explanation:
xyyxyyxyxyxxy is the correct answer to “What will be the output of the following Python code snippet? print('xyyxyyxyxyxxy'.replace('xy', '12', 0))”. 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
To concatenate two strings to a third what statements are applicable?
Correct Answer: Option C — s3 = s1.__add__(s2)
Detailed Academic Explanation:
s3 = s1.__add__(s2) is the correct answer to “To concatenate two strings to a third what statements are applicable”. 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
If a class defines the __str__(self) method, for an object obj for the class, you can use which command to invoke the __str__ method.
Correct Answer: Option D — all of the mentioned
Detailed Academic Explanation:
all of the mentioned is the correct answer to “If a class defines the __str__(self) method, for an object obj for the class, you can use which command to invoke the __str__ method.”. 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
Which of the following statement prints hello\example\test.txt?
Correct Answer: Option B — print(“hello\\example\\test.txt”)
Detailed Academic Explanation:
print(“hello\\example\\test.txt”) is the correct answer to “Which of the following statement prints hello\example\test.txt”. 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('abc'.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('abc'.islower())”. 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 statement? >>>print(chr(ord('b')+1))
Correct Answer: Option C — c
Detailed Academic Explanation:
c is the correct answer to “What will be the output of the following Python statement? >>>print(chr(ord('b')+1))”. 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("abcdef".center(10, '12'))
Correct Answer: Option D — error
Detailed Academic Explanation:
error is the correct answer to “What will be the output of the following Python code? print("abcdef".center(10, '12'))”. 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? >>> str1 = 'hello' >>> str2 = ',' >>> str3 = 'world' >>> str1[-1:]
Correct Answer: Option D — o
Detailed Academic Explanation:
o is the correct answer to “What will be the output of the following Python code? >>> str1 = 'hello' >>> str2 = ',' >>> str3 = 'world' >>> str1[-1:]”. 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 will be the output of the following Python code? print("xyyzxyzxzxyy".count('xyy', 0, 100))
Correct Answer: Option A — 2
Detailed Academic Explanation:
2 is the correct answer to “What will be the output of the following Python code? print("xyyzxyzxzxyy".count('xyy', 0, 100))”. 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 code? print(''' \tfoo'''.lstrip())
Correct Answer: Option B — foo
Detailed Academic Explanation:
foo is the correct answer to “What will be the output of the following Python code? print(''' \tfoo'''.lstrip())”. 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
hat will be the output of the following Python code snippet? print('my_string'.isidentifier())
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “hat will be the output of the following Python code snippet? print('my_string'.isidentifier())”. 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? >>>example = "snow world" >>>print("%s" % example[4:7])
Correct Answer: Option A — wo
Detailed Academic Explanation:
wo is the correct answer to “What will be the output of the following Python code? >>>example = "snow world" >>>print("%s" % example[4: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("Hello {1} and {0}".format('bin', 'foo'))
Correct Answer: Option A — Hello foo and bin
Detailed Academic Explanation:
Hello foo and bin is the correct answer to “What will be the output of the following Python code? print("Hello {1} and {0}".format('bin', 'foo'))”. 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
Say s="hello" what will be the return value of type(s)?
Correct Answer: Option C — str
Detailed Academic Explanation:
str is the correct answer to “Say s="hello" what will be the return value of type(s)”. 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 function do you use to read a string?
Correct Answer: Option A — input("Enter a string")
Detailed Academic Explanation:
input("Enter a string") is the correct answer to “What function do you use to read a string”. 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.