Multiplication
suggest changea, b = 2, 3
a * b # = 6
import operator
operator.mul(a, b) # = 6
Possible combinations (builtin types):
intandint(gives anint)intandfloat(gives afloat)intandcomplex(gives acomplex)floatandfloat(gives afloat)floatandcomplex(gives acomplex)complexandcomplex(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