Multiplication
suggest changea, b = 2, 3
a * b # = 6
import operator
operator.mul(a, b) # = 6
Possible combinations (builtin types):
int
andint
(gives anint
)int
andfloat
(gives afloat
)int
andcomplex
(gives acomplex
)float
andfloat
(gives afloat
)float
andcomplex
(gives acomplex
)complex
andcomplex
(gives acomplex
)
Note: The \*
operator is also used for repeated concatenation of strings, lists, and tuples:
3 * 'ab' # = 'ababab'
3 * ('a', 'b') # = ('a', 'b', 'a', 'b', 'a', 'b')
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents