Share Your Feedback

Learn Python String Methods & Formatting with MCQs.

Test your Python skills with MCQs on string methods and formatting. Great for beginners learning Python strings through hands-on practice.

๐Ÿ“ Multiple Choice Questions

๐ŸŸข Beginner

Q1. What will be the output of the following code?

name = "Alice"
print(name[1])
  1. A
  2. l
  3. i
  4. e
Answer

l

Indexing in strings starts at 0, so `name[1]` gives the second character, which is 'l'.


Q2. Which method converts a string to all uppercase letters?

  1. capitalize()
  2. upper()
  3. title()
  4. swapcase()
Answer

upper()

The `upper()` method converts all characters in a string to uppercase.


Q3. What does the `strip()` method do?

  1. Removes only leading spaces
  2. Removes only trailing spaces
  3. Removes both leading and trailing spaces
  4. Removes all spaces inside the string
Answer

Removes both leading and trailing spaces

The `strip()` method removes whitespace from both ends of the string.


Q4. What is the output of the following code?

word = "HELLO"
print(word.lower())
  1. Hello
  2. hello
  3. HELLO
  4. error
Answer

hello

The `lower()` method converts all uppercase letters in a string to lowercase.


Q5. Which method converts a string to all uppercase letters?

text = "python"
print(text.title())
  1. capitalize()
  2. upper()
  3. title()
  4. swapcase()
Answer

upper()

The `upper()` method converts all characters in a string to uppercase.


Q6. What does the `strip()` method do?

  1. Removes only leading spaces
  2. Removes only trailing spaces
  3. Removes both leading and trailing spaces
  4. Removes all spaces inside the string
Answer

Removes both leading and trailing spaces

The `strip()` method removes whitespace from both ends of the string.


Q7. What is the output of the following code?

word = "HELLO"
print(word.lower())
  1. Hello
  2. hello
  3. HELLO
  4. error
Answer

hello

The `lower()` method converts all uppercase letters in a string to lowercase.


Q8. What is the output of the following code?

text = "python"
print(text.title())
  1. Python
  2. PYTHON
  3. python
  4. P y t h o n
Answer

Python

The `title()` method capitalizes the first letter of each word in the string.


๐ŸŸก Intermediate

๐Ÿ”ด Advanced


๐Ÿง  Practice & Progress

Explore More Topics

๐Ÿฃ Python for Beginners

๐Ÿง  Python Advanced