Python is being weird again. When I put 5 * (40 ^ 2) + 50 * 40 + 100
it returns 2310. But on a calculator its 10100. I don't know why Python is making this mistake nor how to fix it. Anyone got any ideas?
Asked
Active
Viewed 48 times
-1

Lloyd
- 95
- 1
- 8
-
`^` is not `**` ... you are using a binary XOR of 40 and 2 – Patrick Artner Jan 09 '22 at 15:58
2 Answers
1
If you will write
print( 5 * 40 ** 2 + 50 * 40 + 100 )
you will get the expected result.
10100

Vlad from Moscow
- 301,070
- 26
- 186
- 335