Home
MCQS
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))
1abcdef
abcdef1
abcdef
error
2. What will be the output of the following Python code? print("abcdef".center(7, '1'))
1abcdef
abcdef1
abcdef
error
3. What will be the output of the following Python code? print("abcdef".center(10, '12'))
12abcdef12
abcdef1212
1212abcdef
error
4. What will be the output of the following Python code? print("xyyzxyzxzxyy".count('yy'))
2
0
error
none of the mentioned
5. What will be the output of the following Python code? print("xyyzxyzxzxyy".count('yy', 1))
2
0
1
none of the mentioned
6. What will be the output of the following Python code? print("xyyzxyzxzxyy".count('yy', 2))
2
0
1
none of the mentioned
7. What will be the output of the following Python code? print("xyyzxyzxzxyy".count('xyy', 0, 100))
2
0
1
error
8. What will be the output of the following Python code? print("xyyzxyzxzxyy".count('xyy', 2, 11))
2
0
1
error
9. What will be the output of the following Python code? print("xyyzxyzxzxyy".count('xyy', -10, -1))
2
0
1
error
10. What will be the output of the following Python code? print('abc'.encode())
abc
‘abc’
b’abc’
h’abc’
11. What is the default value of encoding in encode()?
ascii
qwerty
utf-8
utf-16
12. What will be the output of the following Python code? print("xyyzxyzxzxyy".endswith("xyy"))
1
True
3
2
13. What will be the output of the following Python code? print("xyyzxyzxzxyy".endswith("xyy", 0, 2))
0
1
True
False
14. What will be the output of the following Python code? print("ab cd ef".expandtabs())
ab cd ef
abcdef
ab cd ef
ab cd ef
15. What will be the output of the following Python code? print("ab cd ef".expandtabs(4))
ab cd ef
abcdef
ab cd ef
ab cd ef
16. What will be the output of the following Python code? print("ab cd ef".expandtabs('+'))
ab+cd+ef
ab++++++++cd++++++++ef
ab cd ef
none of the mentioned
17. What will be the output of the following Python code? print("abcdef".find("cd") == "cd" in "abcdef")
True
False
Error
none of the mentioned
18. What will be the output of the following Python code? print("abcdef".find("cd"))
True
2
3
none of the mentioned
19. What will be the output of the following Python code? print("ccdcddcd".find("c"))
4
0
Error
True
20. What will be the output of the following Python code? print("Hello {0} and {1}".format('foo', 'bin'))
Hello foo and bin
Hello {0} and {1} foo bin
Error
Hello 0 and 1
21. What will be the output of the following Python code? print("Hello {1} and {0}".format('bin', 'foo'))
Hello foo and bin
Hello bin and foo
Error
none of the mentioned
22. What will be the output of the following Python code? print("Hello {} and {}".format('foo', 'bin'))
Hello foo and bin
Hello {} and {}
Error
Hello and
23. What will be the output of the following Python code? print("Hello {name1} and {name2}".format('foo', 'bin'))
Hello foo and bin
Hello {name1} and {name2}
Error
Hello and
24. What will be the output of the following Python code? print("Hello {name1} and {name2}".format(name1='foo', name2='bin'))
Hello foo and bin
Hello {name1} and {name2}
Error
Hello and
25. What will be the output of the following Python code? print("Hello {0!r} and {0!s}".format('foo', 'bin'))
Hello foo and foo
Hello ‘foo’ and foo
Hello foo and ‘bin’
Error
26. What will be the output of the following Python code? print("Hello {0} and {1}".format(('foo', 'bin')))
Hello foo and bin
Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)
Error
None of the mentioned
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))
The sum of 2 and 10 is 12
Error
The sum of 0 and 1 is 2
none of the mentioned
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))
The sum of 2 and 10 is 12
The sum of 10 and a is 14
The sum of 10 and a is c
Error
29. What will be the output of the following Python code snippet? print('{:,}'.format(1112223334))
1,112,223,334
111,222,333,4
1112223334
error
30. What will be the output of the following Python code snippet? print('{:,}'.format('1112223334'))
1,112,223,334
111,222,333,4
1112223334
error
31. What will be the output of the following Python code snippet? print('{:$}'.format(1112223334))
1,112,223,334
111,222,333,4
1112223334
error
32. What will be the output of the following Python code snippet? print('{:#}'.format(1112223334))
1,112,223,334
111,222,333,4
1112223334
1112223334
33. What will be the output of the following Python code? print('{0:.2}'.format(1/3))
0.333333
0.33
0.333333:.2
Error
34. What will be the output of the following Python code? print('ab12'.isalnum())
True
False
None
error
35. What will be the output of the following Python code? print('ab,12'.isalnum())
True
False
None
error
36. What will be the output of the following Python code? print('ab'.isalpha())
True
False
None
Error
37. What will be the output of the following Python code? print('a B'.isalpha())
True
False
None
Error
38. What will be the output of the following Python code snippet? print('0xa'.isdigit())
True
False
None
Error
39. What will be the output of the following Python code snippet? print(''.isdigit())
True
False
None
Error
40. What will be the output of the following Python code snippet? print('my_string'.isidentifier())
True
False
None
Error
41. What will be the output of the following Python code snippet? print('__foo__'.isidentifier())
True
False
None
Error
42. What will be the output of the following Python code snippet? print('for'.isidentifier())
True
False
None
Error
43. What will be the output of the following Python code snippet? print('abc'.islower())
True
False
None
Error
44. What will be the output of the following Python code snippet? print('a@ 1,'.islower())
True
False
None
error
45. What will be the output of the following Python code snippet? print('11'.isnumeric())
True
False
None
Error
46. What will be the output of the following Python code snippet? print('1.1'.isnumeric())
True
False
None
Error
47. What will be the output of the following Python code snippet? print('1@ a'.isprintable())
True
False
None
Error
48. What will be the output of the following Python code snippet? print(''''''.isspace())
True
False
None
Error
49. What will be the output of the following Python code snippet? print(' '.isspace())
True
False
None
Error
50. What will be the output of the following Python code snippet? print('HelloWorld'.istitle())
True
False
None
Error
Submit