NEW
Font size
WorksheetsMastering Python Strings
Total questions: 10
Worksheet time: 5mins
What method would you use to convert a string to lowercase?
.lower() or .toLowerCase()
.upper()
convertToLower()
string.toLower()
How do you concatenate two strings in Python?
Use the '&' operator to combine strings.
Use the '+' operator to concatenate strings.
Use the '*' operator to concatenate strings.
Use the 'concat()' method to join strings.
What is the output of 'Hello, World!'[7:12]?
lo, Wo
World!
World
Hello
Which method removes whitespace from the beginning and end of a string?
removeSpaces
trim
clearWhitespace
strip
How can you check if a substring exists within a string?
Use the 'in' operator in Python or 'contains' method in Java.
Use the 'indexOf' method in C++
Check the length of the string
Use the 'find' method in Python
What does the method .replace() do in a string?
The .replace() method removes all whitespace from a string.
The .replace() method converts a string to uppercase.
The .replace() method splits a string into an array.
The .replace() method replaces specified substrings in a string with new substrings.
How do you access the first character of a string?
Use string[0] to access the first character of a string.
Use string.first() to get the first character.
Access the first character with string.charAt(0).
Retrieve the first character using string.slice(1).
What is the result of 'Python' * 3?
PythonPythonPython!
PythonPythonPython
PythonPython
Python3
How can you find the length of a string in Python?
length(your_string)
your_string.length()
string.length(your_string)
len(your_string)
What does the method .split() do to a string?
.split() removes all whitespace from a string.
.split() divides a string into a list of substrings.
.split() concatenates multiple strings into one.
.split() converts a string to uppercase.
