Python MCQ Quiz Hub

Python Mcq Set 6

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

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





✅ Correct Answer: 4

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





✅ Correct Answer: 1

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





✅ Correct Answer: 4

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





✅ Correct Answer: 1

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





✅ Correct Answer: 1

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





✅ Correct Answer: 3

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





✅ Correct Answer: 1

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





✅ Correct Answer: 2

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





✅ Correct Answer: 2

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





✅ Correct Answer: 3

What is the default value of encoding in encode()?





✅ Correct Answer: 3

What will be the output of the following Python code? print("xyyzxyzxzxyy".endswith("xyy"))





✅ Correct Answer: 2

What will be the output of the following Python code? print("xyyzxyzxzxyy".endswith("xyy", 0, 2))





✅ Correct Answer: 4

What will be the output of the following Python code? print("ab cd ef".expandtabs())





✅ Correct Answer: 1

What will be the output of the following Python code? print("ab cd ef".expandtabs(4))





✅ Correct Answer: 4

What will be the output of the following Python code? print("ab cd ef".expandtabs('+'))





✅ Correct Answer: 4

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





✅ Correct Answer: 2

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





✅ Correct Answer: 1

What will be the output of the following Python code? print("ccdcddcd".find("c"))





✅ Correct Answer: 2

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





✅ Correct Answer: 1

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





✅ Correct Answer: 1

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





✅ Correct Answer: 1

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





✅ Correct Answer: 3

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





✅ Correct Answer: 1

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





✅ Correct Answer: 2

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





✅ Correct Answer: 3

What will be the output of the following Python code snippet? print('The sum of {0} and {1} is {2}'.format(2, 10, 12))





✅ Correct Answer: 1

hat will be the output of the following Python code snippet? print('The sum of {0:b} and {1:x} is {2:o}'.format(2, 10, 12))





✅ Correct Answer: 2

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





✅ Correct Answer: 1

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





✅ Correct Answer: 4

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





✅ Correct Answer: 4

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





✅ Correct Answer: 3

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





✅ Correct Answer: 2

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





✅ Correct Answer: 1

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





✅ Correct Answer: 2

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





✅ Correct Answer: 1

What will be the output of the following Python code? print('a B'.isalpha())





✅ Correct Answer: 2

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





✅ Correct Answer: 2

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





✅ Correct Answer: 2

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





✅ Correct Answer: 1

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





✅ Correct Answer: 1

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





✅ Correct Answer: 1

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





✅ Correct Answer: 1

What will be the output of the following Python code snippet? print('a@ 1,'.islower())





✅ Correct Answer: 1

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





✅ Correct Answer: 1

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





✅ Correct Answer: 2

What will be the output of the following Python code snippet? print('1@ a'.isprintable())





✅ Correct Answer: 1

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





✅ Correct Answer: 2

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





✅ Correct Answer: 1

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





✅ Correct Answer: 2