Python MCQ Quiz Hub

Python Mcq Set 6

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

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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




28. 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))




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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




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