Python MCQ – String – 10

This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Strings – 10”.

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: The .isidentifier() method checks whether a string is a valid identifier according to Python’s syntax rules — it doesn’t check whether the string is a keyword. ‘for’ follows the syntax rules for identifiers, so .isidentifier() returns True, even though ‘for’ is a Python keyword and can’t actually be used as a variable name.
advertisement

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: The .islower() method returns True if all alphabetic characters in the string are lowercase and there is at least one alphabetic character. Since ‘abc’ contains only lowercase letters, the result is True.
⚡ Hurry! Secure Your Free Cyber Security Certification - December 2025

3. What will be the output of the following Python code snippet?

advertisement
print('a@ 1,'.islower())

a) True
b) False
c) None
d) Error
View Answer

Answer: a
Explanation: The .islower() method returns True if all alphabetic characters in the string are lowercase, ignoring non-alphabetic characters like @, space, 1, and ,. Since there are no uppercase letters and the alphabetic characters are lowercase, the result is True.

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: The .isnumeric() method returns True if all characters in the string are numeric characters. Since ’11’ contains only numeric digits, the method returns True.

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 .isnumeric() method returns True only if all characters in the string are numeric characters. Since the string ‘1.1’ contains a dot . which is not numeric, the method returns False.

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: The .isprintable() method returns True if all characters in the string are printable, including letters, digits, punctuation, and whitespace. Since ‘1@ a’ contains only printable characters, the result is True.

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: The string ””’ is an empty string (no characters). The .isspace() method returns True only if all characters in the string are whitespace characters. Since the string is empty and contains no characters at all, .isspace() returns False.

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: The .isspace() method returns True if all characters in the string are whitespace characters, which include spaces, tabs (\t), newlines, and similar. Since ‘\t’ is a tab character, it counts as whitespace, so the result is True.

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 .istitle() method checks if each word in the string starts with an uppercase letter followed by lowercase letters. In ‘HelloWorld’, Python treats it as a single word with multiple uppercase letters, which violates the title case rule. Therefore, the output is False.

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

Answer: a
Explanation: The .istitle() method returns True if each word in the string starts with an uppercase letter followed by lowercase letters. In ‘Hello World’, both “Hello” and “World” follow this rule, so the method returns True.

Sanfoundry Global Education & Learning Series – Python.

To practice all test questions on Python, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
I’m Manish - Founder and CTO at Sanfoundry. I’ve been working in tech for over 25 years, with deep focus on Linux kernel, SAN technologies, Advanced C, Full Stack and Scalable website designs.

You can connect with me on LinkedIn, watch my Youtube Masterclasses, or join my Telegram tech discussions.

If you’re in your 20s–40s and exploring new directions in your career, I also offer mentoring. Learn more here.