Recall & Review
beginner Click to reveal answer
What is string concatenation?
String concatenation is joining two or more strings together to make one longer string.
beginner Click to reveal answer
How do you concatenate strings in Python?
Use the + operator to join strings. For example, 'Hello' + ' ' + 'World' results in 'Hello World'.
beginner Click to reveal answer
What does string repetition mean?
String repetition means repeating the same string multiple times in a row.
beginner Click to reveal answer
How do you repeat a string in Python?
Use the * operator with an integer. For example, 'ha' * 3 results in 'hahaha'.
intermediate Click to reveal answer
What is the output of this code: 'Hi' + '!' * 3?
The output is 'Hi!!!' because '!' is repeated 3 times and then concatenated with 'Hi'.
Which operator is used to join two strings in Python?
✗ Incorrect
The + operator joins (concatenates) two strings.
What does 'abc' * 2 produce?
✗ Incorrect
The * operator repeats the string twice, so 'abcabc'.
What is the result of 'Hello' + ' ' + 'World'?
✗ Incorrect
The strings are joined with a space in between, resulting in 'Hello World'.
Which of these is NOT a valid way to concatenate strings in Python?
✗ Incorrect
The - operator cannot be used with strings.
What will '!' * 0 return?
✗ Incorrect
Repeating a string zero times returns an empty string.
Explain how to join two strings and repeat a string in Python with examples.
Think about using + to add strings and * to repeat them.
You got /4 concepts.
What happens if you multiply a string by zero or a negative number in Python?
Consider how repetition count affects the output.
You got /3 concepts.
