"fred" x 3 # is "fredfredfred"
"barney" x (4+1) # is "barney" x 5, or "barneybarneybarneybarneybarney"
5 x 4 # is really "5" x 4, which is "5555"
That last example is worth spelling out slowly. The string repetition
operator wants a string for a left operand, so the number
5 is converted to the string
"5" (using rules described in detail later),
giving a one-character string. This new string is then copied four
times, yielding the four-character string 5555.
Note that if we had reversed the order of the operands, as 4
x 5, we would have made five copies of the string
4, yielding 44444. This shows
that string repetition is not commutative.
The copy count (the right operand) is first truncated to an integer
value (4.8 becomes 4) before being used. A copy count of less than
one results in an empty (zero-length) string.