What's the difference between “2*2” and “2**2” in Python?

前端 未结 10 1125
小蘑菇
小蘑菇 2020-12-30 18:36

What is the difference between the following codes?

code1:

var=2**2*3

code2:

var2         


        
10条回答
  •  太阳男子
    2020-12-30 18:58

    The top one is a "power" operator, so in this case it is the same as 2 * 2 equal to is 2 to the power of 2. If you put a 3 in the middle position, you will see a difference.

提交回复
热议问题