0

print(9^10) in python

The output is 3..What is the logic or explanation behind this

13th Jun 2021, 5:21 AM
Rajulapudi Aswini
Rajulapudi Aswini - avatar
2 Answers
+ 8
It is Bitwise XOR operator. It based on binary 9 = 00001001 10= 00001010 ----------------- 3 = 00000011 ^ which give 1 if both digits are different. Otherwise give 0. https://www.sololearn.com/learn/4074/?ref=app https://www.sololearn.com/learn/4070/?ref=app
13th Jun 2021, 5:31 AM
Vadivelan
+ 3
because '^' is the XOR bitwise operator... I guess you want the exponentiation operator wich is '**', so instead try: print(9**10)
13th Jun 2021, 5:32 AM
visph
visph - avatar