Python MCQs
1. What will be the output of the following Python code snippet?
print('for'.isidentifier())
a) True
b) False
c) None
d) Error
View Answer
Answer: a
Explanation: Even keywords are considered as valid identifiers.
2. What will be the output of the following Python code snippet?
print('abc'.islower())
a) True
b) False
c) None
d) Error
View Answer
Answer: a
Explanation: There are no uppercase letters.
3. What will be the output of the following Python code snippet?
print('a@ 1,'.islower())
a) True
b) False
c) None
d) Error
View Answer
Answer: a
Explanation: There are no uppercase letters.
4. What will be the output of the following Python code snippet?
print('11'.isnumeric())
a) True
b) False
c) None
d) Error
View Answer
Answer: a
Explanation: All the character are numeric.
5. What will be the output of the following Python code snippet?
print('1.1'.isnumeric())
a) True
b) False
c) None
d) Error
View Answer
Answer: b
Explanation: The character . is not a numeric character.
6. What will be the output of the following Python code snippet?
print('1@ a'.isprintable())
a) True
b) False
c) None
d) Error
View Answer
Answer: a
Explanation: All those characters are printable.
7. What will be the output of the following Python code snippet?
print(''''''.isspace())
a) True
b) False
c) None
d) Error
View Answer
Answer: b
Explanation: None.
8. What will be the output of the following Python code snippet?
print('\t'.isspace())
a) True
b) False
c) None
d) Error
View Answer
Answer: a
Explanation: Tab Spaces are considered as spaces.
9. What will be the output of the following Python code snippet?
print('HelloWorld'.istitle())
a) True
b) False
c) None
d) Error
View Answer
Answer: b
Explanation: The letter W is uppercased.
10. What will be the output of the following Python code snippet?
print('Hello World'.istitle())
a) True
b) False
c) None
d) Error
View Answer
Explanation: It is in title form.