Python “-1” exponentiation issue

后端 未结 0 1449
忘掉有多难
忘掉有多难 2020-11-28 19:48

Can anyone explain why that seem equal expressions give different results?

def foo(n):
    print(n) # -1
    print(-1 ** 0.5) # -1.0
    print(n ** 0.5) # (6.         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题