Recall & Review
beginner
What does the
len() function do when used with a string?The
len() function returns the number of characters in the string, including spaces and special characters.Click to reveal answer
beginner
How can you check if a character or substring exists inside a string in Python?
You can use the
in keyword to test membership. For example, 'a' in 'apple' returns True.Click to reveal answer
beginner
What will
len('Hello World') return?It will return
11 because there are 11 characters including the space.Click to reveal answer
beginner
What is the result of
'x' in 'example'?It returns
True because the character 'x' is present in the string 'example'.Click to reveal answer
beginner
Can
in be used to check for substrings longer than one character?Yes,
in works for any substring. For example, 'cat' in 'concatenate' returns True.Click to reveal answer
What does
len('Python') return?✗ Incorrect
len() counts all characters. 'Python' has 6 letters.Which expression checks if 'a' is in the string 'data'?
✗ Incorrect
The
in keyword checks membership. 'a' in 'data' is True.What will
'z' in 'pizza' return?✗ Incorrect
'z' is present in 'pizza', so the result is True.
What is the length of the string
'' (empty string)?✗ Incorrect
An empty string has zero characters, so length is 0.
Which of these is True?
✗ Incorrect
'cat' is a substring of 'concatenate', so it returns True.
Explain how to find the number of characters in a string and how to check if a character is inside that string.
Think about counting characters and searching inside text.
You got /4 concepts.
Describe what happens when you use
in with a substring longer than one character.Consider if 'cat' is in 'concatenate'.
You got /3 concepts.