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

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

What is the difference between the following codes?

code1:

var=2**2*3

code2:

var2         


        
10条回答
  •  自闭症患者
    2020-12-30 19:03

    Try:

    2**3*2
    

    and

    2*3*2
    

    to see the difference.

    ** is the operator for "power of". In your particular operation, 2 to the power of 2 yields the same as 2 times 2.

提交回复
热议问题