Sujet : Re: Multiplication
De : piergiorgio.sartor.this.should.not.be.used (at) *nospam* nexgo.REMOVETHIS.de (Piergiorgio Sartor)
Groupes : comp.lang.pythonDate : 01. Apr 2024, 09:51:05
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <p49qdk-ea6.ln1@lazy.lzy>
References : 1
User-Agent : Mozilla Thunderbird
On 01/04/2024 10.40, Stefan Ram wrote:
Q: How can I multiply two variables in Python? I tried:
a = 2
b = 3
print( ab )
but it did not work.
A: No, this cannot work. To multiply, you need the multiplication
operator. You can import the multiplication operator from "math":
Code example:
from math import *
a = 2
b = 3
print( a * b )
I guess the operator "*" can be imported from any module... :-)
bye,
-- piergiorgio