0

What should be the value of 0^0 in python programming? I am getting 0 which should be 1. Please clarify.

9th May 2020, 4:12 PM
SHAKTIYAVESH NANDAN PRATAP SINGH
20 Antworten
+ 7
^ is the bitwise XOR operator in Python, so if you did print(0^0), you should get 0.
9th May 2020, 4:19 PM
Kishalaya Saha
Kishalaya Saha - avatar
+ 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.
9th May 2020, 4:14 PM
Denise Roßberg
Denise Roßberg - avatar
+ 3
Thank you Denise Roßberg , Bahha🐧 and Kishalaya Saha. Actually I was mistakenly edited XOR operation. Thanks once again.
9th May 2020, 4:36 PM
SHAKTIYAVESH NANDAN PRATAP SINGH
+ 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."
9th May 2020, 6:22 PM
Tibor Santa
Tibor Santa - avatar
+ 2
Because in python ^ is a bitwise or. And if you want to take power use ** as 2**2=4 , 0**0=1
11th May 2020, 8:39 AM
Pavan Barve
Pavan Barve - avatar
+ 1
what did you use? print(pow(0,0)) = 1
9th May 2020, 4:16 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 1
Denise Roßberg But 0^n is always 0 😉 Actually 0^0 is undefined in maths.
9th May 2020, 4:36 PM
Russ
Russ - avatar
+ 1
Russ Thank you. You are right.
9th May 2020, 4:44 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Tibor Santa Didn't realise that, thanks!
9th May 2020, 6:25 PM
Russ
Russ - avatar
+ 1
ThanksTibor Santa .
9th May 2020, 6:33 PM
SHAKTIYAVESH NANDAN PRATAP SINGH
+ 1
Python does not recognize ^ as exponential, you need to use **.
9th May 2020, 7:04 PM
Jibril Balogun
Jibril Balogun - avatar
+ 1
Bahha🐧 So it's like 0 raised to 0 then?
11th May 2020, 1:15 AM
Epsilon ︻╦̵̵͇̿̿̿̿╤──
Epsilon ︻╦̵̵͇̿̿̿̿╤── - avatar
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
9th May 2020, 4:44 PM
SHAKTIYAVESH NANDAN PRATAP SINGH
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.
9th May 2020, 5:12 PM
Russ
Russ - avatar
10th May 2020, 4:07 AM
SHAKTIYAVESH NANDAN PRATAP SINGH
10th May 2020, 1:27 PM
SHAKTIYAVESH NANDAN PRATAP SINGH
0
What is the binary value of 0? It is 0000. So therefore 0000 ^ 0000 -------- 0000
10th May 2020, 4:04 PM
Epsilon ︻╦̵̵͇̿̿̿̿╤──
Epsilon ︻╦̵̵͇̿̿̿̿╤── - avatar
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.
10th May 2020, 5:41 PM
Bahhaⵣ
Bahhaⵣ - avatar
0
Yes i would also like to know
11th May 2020, 1:18 PM
Rakesh Yadav
- 2
Why should it be one it is simple the value is going to be 0
10th May 2020, 6:57 AM
𝖆𝖊𝖙𝖍𝖊𝖗
𝖆𝖊𝖙𝖍𝖊𝖗 - avatar