Skip to main content

Strings In Python — Part 2 MCQs with Explanations

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
Question 1 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? print('abcd'.translate('a'.maketrans('abc', 'bcd')))

Question 2 of 40
★ FPSC ★ PPSC

Suppose i is 5 and j is 4, i + j is same as . . . . . . . .

Question 3 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? print('abcdefcdghcd'.split('cd'))

Question 4 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? print("ab\tcd\tef".expandtabs('+'))

Question 5 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? print('+99'.zfill(5))

Question 6 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? print("abcdef".center(0))

Question 7 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? print('a'.maketrans('ABC', '123'))

Question 8 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? print('abcdefcdghcd'.split('cd', 0))

Question 9 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? print("Hello {} and {}".format('foo', 'bin'))

Question 10 of 40
★ FPSC ★ PPSC

What will be the output of the following Python statement? >>>"abcd"[2:]

Question 11 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? print("Hello {name1} and {name2}".format('foo', 'bin'))

Question 12 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? print('0xa'.isdigit())

Question 13 of 40
★ FPSC ★ PPSC

The output of executing string.ascii_letters can also be achieved by:

Question 14 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? print('{:,}'.format(1112223334))

Question 15 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? print('{0:.2%}'.format(1/3))

Question 16 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? print("abcdef".center(7, '1'))

Question 17 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? print('xyxxyyzxxy'.lstrip('xyy'))

Question 18 of 40
★ FPSC ★ PPSC

The format function, when applied on a string returns . . . . . . . .

Question 19 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? print('ab,12'.isalnum())

Question 20 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? print("xyyzxyzxzxyy".count('yy', 2))

Question 21 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? print("abcdef".find("cd") == "cd" in "abcdef")

Question 22 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? print("Hello {0} and {1}".format(('foo', 'bin')))

Question 23 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? print("abcdef".center())

Question 24 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? >>>example = "snow world" >>>example[3] = 's' >>>print example

Question 25 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? print('\t'.isspace())

Question 26 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? print('xyyxyyxyxyxxy'.replace('xy', '12', 0))

Question 27 of 40
★ FPSC ★ PPSC

To concatenate two strings to a third what statements are applicable?

Question 28 of 40
★ 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.

Question 29 of 40
★ FPSC ★ PPSC

Which of the following statement prints hello\example\test.txt?

Question 30 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? print('abc'.islower())

Question 31 of 40
★ FPSC ★ PPSC

What will be the output of the following Python statement? >>>print(chr(ord('b')+1))

Question 32 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? print("abcdef".center(10, '12'))

Question 33 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? >>> str1 = 'hello' >>> str2 = ',' >>> str3 = 'world' >>> str1[-1:]

Question 34 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? print("xyyzxyzxzxyy".count('xyy', 0, 100))

Question 35 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? print(''' \tfoo'''.lstrip())

Question 36 of 40
★ FPSC ★ PPSC

hat will be the output of the following Python code snippet? print('my_string'.isidentifier())

Question 37 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? >>>example = "snow world" >>>print("%s" % example[4:7])

Question 38 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? print("Hello {1} and {0}".format('bin', 'foo'))

Question 39 of 40
★ FPSC ★ PPSC

Say s="hello" what will be the return value of type(s)?

Question 40 of 40
★ FPSC ★ PPSC

What function do you use to read a string?

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 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.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →