Liste des Groupes | Revenir à cl python |
>
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
>
--
https://mail.python.org/mailman/listinfo/python-list
15a = 3
b = 5
print(a*b)
>
Date | Sujet | # | Auteur | |
1 Apr 24 | Multiplication | 6 | Stefan Ram | |
1 Apr 24 | Re: Multiplication | 5 | Piergiorgio Sartor | |
1 Apr 24 | Re: Multiplication | 1 | Joel Goldstick | |
1 Apr 24 | Re: Multiplication | 1 | D'Arcy Cain | |
1 Apr 24 | Re: Multiplication | 1 | Avi Gross | |
1 Apr 24 | Re: Multiplication | 1 | dn |
Les messages affichés proviennent d'usenet.