Skip to content Skip to sidebar Skip to footer

Why Doesn't Python Use ^ To Denote Squaring A Number But Uses ** Instead?

A few languages I've seen utilise the ^ symbol, and it doesn't seem to be reserved for anything in Python. It sort of confuses me as well since the ^ symbol is (very) well known an

Solution 1:

As Guido says "Python’s first and foremost influence was ABC, a language designed in the early 1980s by Lambert Meertens, Leo Geurts and others at CWI.". x raised to the power y was implemented as x**y in ABC. ABC itself was influenced by SETL & ALGOL 68.

Solution 2:

Because ^ is the bitwise XOR operator. This is the same for many languages, including C, C++, C#, Java, Perl, PHP, Ruby, and certainly others.

Solution 3:

FORTRAN is another language that uses the ** notation for power. It predates both Python and C by a lot, so perhaps it was an influence on the BDFL.

Post a Comment for "Why Doesn't Python Use ^ To Denote Squaring A Number But Uses ** Instead?"