Skip to main content

Conditional Formatting _While And For Loops — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Conditional Formatting _While And For Loops — 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? for i in range(2.0): print(i)

Question 2 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? for i in range(int(2.0)): print(i)

Question 3 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? for i in ''.join(reversed(list('abcd'))): print (i)

Question 4 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? x = 2 for i in range(x): x += 1 print (x)

Question 5 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? for i in range(float('inf')): print (i)

Question 6 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? for i in range(int(float('inf'))): print (i)

Question 7 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? x = 2 for i in range(x): x -= 2 print (x)

Question 8 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = 123 for i in x: print(i)

Question 9 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? d = {0, 1, 2} for x in d: print(x)

Question 10 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? d = {0, 1, 2} for x in d.values(): print(x)

Question 11 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? d = {0: 'a', 1: 'b', 2: 'c'} for i in d: print(i)

Question 12 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? d = {0: 'a', 1: 'b', 2: 'c'} for x, y in d.items(): print(x, y)

Question 13 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? d = {0, 1, 2} for x in d: print(d.add(x))

Question 14 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? d = {0: 'a', 1: 'b', 2: 'c'} for x in d.keys(): print(d[x])

Question 15 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? d = {0: 'a', 1: 'b', 2: 'c'} for x in d.values(): print(x)

Question 16 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? d = {0: 'a', 1: 'b', 2: 'c'} for x in d.values(): print(d[x])

Question 17 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? d = {0: 'a', 1: 'b', 2: 'c'} for x, y in d: print(x, y)

Question 18 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? for i in range(0): print(i)

Question 19 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = 'abcd' for i in range(x): print(i)

Question 20 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? x = 'abcd' for i in range(len(x)): print(x) x = 'a'

Question 21 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? x = 'abcd' for i in range(len(x)): i.upper() print (x)

Question 22 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? x = 'abcd' for i in range(len(x)): x[i].upper() print (x)

Question 23 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? x = 'abcd' for i in range(len(x)): i[x].upper() print (x)

Question 24 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = 'abcd' for i in range(len(x)): print(i.upper())

Question 25 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = 'abcd' for i in x: print(i) x.upper()

Question 26 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? x = 'abcd' for i in range(len(x)): x = 'a' print(x)

Question 27 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = "abcdef" while i in x: print(i, end=" ")

Question 28 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = "abcdef" i = "a" while i in x: x = x[1:] print(i, end = " ")

Question 29 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = "abcdef" i = "a" while i in x[1:]: print(i, end = " ")

Question 30 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = "abcdef" i = "i" while i in x: print(i, end=" ")

Question 31 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? i = 0 while i < 3: print(i) i += 1 else: print(0)

Question 32 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? i = 0 while i < 5: print(i) i += 1 if i == 3: break else: print(0)

Question 33 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = "abcdef" i = "a" while i in x: print(i, end = " ")

Question 34 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? i = 2 while True: if i%3 == 0: break print(i) i += 2

Question 35 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? i = 1 while True: if i%2 == 0: break print(i) i += 2

Question 36 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x = ['ab', 'cd'] for i in x: x.append(i.upper()) print(x)

Question 37 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? i = 5 while True: if i%0O9 == 0: break print(i) i += 1

Question 38 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? True = False while True: print(True) break

Question 39 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? i = 1 while False: if i%2 == 0: break print(i) i += 2

Question 40 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? i = 5 while True: if i%0O11 == 0: break print(i) i += 1

✓ 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 →