Python MCQ Quiz Hub

Python Mcq Set 4

Choose a topic to test your knowledge and improve your Python skills

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





✅ Correct Answer: 1

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





✅ Correct Answer: 4

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





✅ Correct Answer: 1

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





✅ Correct Answer: 2

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





✅ Correct Answer: 4

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





✅ Correct Answer: 4

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





✅ Correct Answer: 4

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





✅ Correct Answer: 4

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





✅ Correct Answer: 4

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





✅ Correct Answer: 4

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)





✅ Correct Answer: 2

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





✅ Correct Answer: 2

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





✅ Correct Answer: 4

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





✅ Correct Answer: 1

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





✅ Correct Answer: 3

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





✅ Correct Answer: 2

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





✅ Correct Answer: 2

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





✅ Correct Answer: 3

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





✅ Correct Answer: 2

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





✅ Correct Answer: 3

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





✅ Correct Answer: 2

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





✅ Correct Answer: 3

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





✅ Correct Answer: 3

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





✅ Correct Answer: 3

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





✅ Correct Answer: 1

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





✅ Correct Answer: 3

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





✅ Correct Answer: 3

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





✅ Correct Answer: 4

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





✅ Correct Answer: 3

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





✅ Correct Answer: 1

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)





✅ Correct Answer: 4

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)





✅ Correct Answer: 3

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])





✅ Correct Answer: 2

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





✅ Correct Answer: 2

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])





✅ Correct Answer: 4

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





✅ Correct Answer: 3

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





✅ Correct Answer: 1

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





✅ Correct Answer: 3

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





✅ Correct Answer: 2

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





✅ Correct Answer: 3

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





✅ Correct Answer: 2

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





✅ Correct Answer: 4

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





✅ Correct Answer: 4

What will be the output of the following Python code snippet? for i in [1, 2, 3, 4][::-1]: print (i)





✅ Correct Answer: 2

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





✅ Correct Answer: 2

What will be the output of the following Python code snippet? for i in 'abcd'[::-1]: print (i)





✅ Correct Answer: 2

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





✅ Correct Answer: 2

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





✅ Correct Answer: 3

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





✅ Correct Answer: 2

What will be the output of the following Python code? for i in range(5): if i == 5: break else: print(i) else: print("Here")





✅ Correct Answer: 1