0
What should be the value of 0^0 in python programming? I am getting 0 which should be 1. Please clarify.
20 odpowiedzi
+ 7
^ is the bitwise XOR operator in Python, so if you did print(0^0), you should get 0.
+ 6
Hello Shaktiyavesh
I think you did something wrong.
print(0**0)
output: 1
Which is correct because n^0 is always 1. So 0^0 is also 1.
+ 3
Thank you Denise Roßberg , Bahha🐧 and Kishalaya Saha. Actually I was mistakenly edited XOR operation. Thanks once again.
+ 2
https://en.m.wikipedia.org/wiki/Zero_to_the_power_of_zero
"In algebra and combinatorics, the generally agreed upon value is 0^0 = 1, whereas in mathematical analysis, the expression is sometimes left undefined."
+ 2
Because in python ^ is a bitwise or. And if you want to take power use ** as 2**2=4 , 0**0=1
+ 1
what did you use?
print(pow(0,0)) = 1
+ 1
Denise Roßberg But 0^n is always 0 😉
Actually 0^0 is undefined in maths.
+ 1
Russ
Thank you. You are right.
+ 1
Tibor Santa Didn't realise that, thanks!
+ 1
ThanksTibor Santa .
+ 1
Python does not recognize ^ as exponential, you need to use **.
+ 1
Bahha🐧 So it's like 0 raised to 0 then?
0
Dear mr. Russ .
You are right as 0^0 is undefined. But in calculator, it takes 1. I wanted to check either of this Or to get some error messages. To get it undefined we may required some more deliberation. Thanks
0
Shaktiyavesh Sure, I was careful to mention "in maths" as that (rightly or wrongly) is a slightly different matter to programming. Unsure as to why Python would return 1 and not an error.
0
ThanksDr. Exceptional
0
Hi Silver
Pls refer this:
https://en.m.wikipedia.org/wiki/Zero_to_the_power_of_zero
0
What is the binary value of 0? It is 0000. So therefore
0000 ^
0000
--------
0000
0
Epsilon ︻╦̵̵͇̿̿̿̿╤── it's not about the value of 0 in binary, it's just a mathematical convenience, which is not agreed upon by everyone.
read the Wikipedia link above.
0
Yes i would also like to know
- 2
Why should it be one it is simple the value is going to be 0