The following code:
print(3 * 'abc' + 'xyz') prints:
- abcabcxyzxyz
- abcabcabcxyz
- xyzxyzxyzxyz
- abcxyzxyzxyz
Explanation: The * and + operators replicate and concatenate when used with strings. The first operation 3 * ‘abc’ returns a string that contains abcabcabc. Then the second operation + ‘xyz’ concatenates xyz to the previous string. The resulting string abcabcabcxyz is printed in the console.
More Questions: Python Essentials 2 – Module 2 Test
Please login or Register to submit your answer