Python Questions and Answers Part-15

1. What will be the output of the following Python code snippet?
print('for'.isidentifier())
a) true
b) false
c) none
d) error

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

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

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

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

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

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

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

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

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

Answer: a
Explanation: It is in title form.