I'm a stubborn guy. So when Codecadamy tells me:
What this actually means to the computer is actually very complicated, so we're not going to get into it.
... I'm still gonna try and find out how it works, because otherwise it'll annoy the heck out of me. Turns out, this was a nice little trip down memory lane, to the days when I studied CS and digital electronics. The key issue here is something called Two's Complement (wikipedia). To quote that wiki-page a bit:
Two's complement is a mathematical operation on binary numbers, as well as a binary signed number representation based on this operation.
- Let's say we're representing the number 1 in byte form: 00000001
- If we perform a bitwise NOT, that becomes 11111110
- Normally this would be interpreted as 255, were it not that:
In two's-complement representation, positive numbers are simply represented as themselves, and negative numbers are represented by the two's complement of their absolute value. [...] This system is the most common method of representing signed integers on computers.
And there in lies the rub! The ~ operator is not a bitwise "NOT", but a bitwise "COMPLEMENT" operator! The title and explanation of 10/14 are slightly misleading. The ~ explicitly tells Python to perform a NOT operation on a byte, into a two's complement representation. See also this article on Python.org.