Test your Python skills with MCQs on string methods and formatting. Great for beginners learning Python strings through hands-on practice.
name = "Alice"
print(name[1])
l
Indexing in strings starts at 0, so `name[1]` gives the second character, which is 'l'.
upper()
The `upper()` method converts all characters in a string to uppercase.
Removes both leading and trailing spaces
The `strip()` method removes whitespace from both ends of the string.
word = "HELLO"
print(word.lower())
hello
The `lower()` method converts all uppercase letters in a string to lowercase.
text = "python"
print(text.title())
upper()
The `upper()` method converts all characters in a string to uppercase.
Removes both leading and trailing spaces
The `strip()` method removes whitespace from both ends of the string.
word = "HELLO"
print(word.lower())
hello
The `lower()` method converts all uppercase letters in a string to lowercase.
text = "python"
print(text.title())
Python
The `title()` method capitalizes the first letter of each word in the string.