The immutability of strings varies by programming language.
True
What operator is used for string concatenation?
+
Strings in programming are zero-indexed
Strings use single or double quotes for enclosure.
True
What is the purpose of string slicing?
Extracting a substring
When used with strings, the `+` operator performs concatenation
String slicing notation uses [start:end].
True
The `+` operator concatenates strings and adds integers.
True
What is string slicing?
Extracting a substring
String slicing returns a new string containing characters from the `start` index up to but not including the `end` index
Negative indexing counts from the end of the string.
True
Match the string manipulation function with its description:
`len(string)` ↔️ Returns the length of the string
`string.upper()` ↔️ Converts the string to uppercase
`string.lower()` ↔️ Converts the string to lowercase
What does the `len()` function return for the string "Hello"?
5
The `find()` method returns -1 if the substring is not found
What error does the `index()` method raise if the substring is not found?
ValueError
The `find()` method returns -1 if the substring is not found
What error does the `index()` method raise if the substring is not found?
ValueError
The `index()` method is useful when you want to ensure the substring is present.
True
The `format()` method uses curly braces as placeholders
F-strings require Python 3.6 or later to function.
True
Strings are always immutable in all programming languages.
False
String slicing extracts a substring from a larger string.
What notation is used for string slicing?
[start:end]
String slicing uses the notation `[start:end]`, where `start` is the index of the first character to include and `end` is the index one position after the last character to include
Negative indices allow you to access characters from the end of the string.
True
What does the `len()` function return?
Number of characters
Match the string method with its description:
`find(substring)` ↔️ Finds the first occurrence of a substring
`index(substring)` ↔️ Raises a ValueError if substring is not found
f-strings were introduced in Python 3.6.
True
F-strings require Python 3.6 or higher.
True
Order the following string formatting features by their introduction in Python versions:
1️⃣ `format()`
2️⃣ f-strings
What is the output of `address[:10]` if `address = "123 Main St, Anytown USA"`?
123 Main St
What does the `len()` function return when applied to a string?
String length
Match the string manipulation method with its description:
upper() ↔️ Converts to uppercase
lower() ↔️ Converts to lowercase
strip() ↔️ Removes whitespace
If the `find()` method does not find the substring, it returns -1.
True
Strings are immutable in all programming languages.
False
Strings are enclosed in single or double quotes
Match the string handling operation with its description: