The Verge: Uber’s new pickup directions and walking ETAs can finally help you escape the airport
Uber’s new pickup directions and walking ETAs can finally help you escape the airport
The official Python documentation explains ord(c) ord (c): Given a string representing one Unicode character, return an integer representing the Unicode code point of that character. For example, ord ('a') returns the integer 97 and ord ('€') (Euro sign) returns 8364. This is the inverse of chr (). It does not specify the meaning of ord, google searches are not helpful. What's the origin of it?
2 ord is a function that takes a character and returns the number that unicode associates that character with. The way unicode structures the digits 0-9 ord("9")-ord("0") will result in 9. ord of 0 is 48 and the digits count up from there: "1" is 49, "2" is 50 etc.
So ord(B[0]) - ord('0') is the int 1 when B[0] is the string '1', and it is the int 0 when B[0] is the string '0'. In short, it is just a way to convert the string to an int. int(B[0]) would have been simpler, but the author is avoiding int, since if you have int then the entire piece of code could be replaced by int(B, 2).
using ord function (ord (B [0]) - ord ('0')) - Stack Overflow
ord () is used to get the ASCII value of the character we insert. Like ord ("A") => 65 Does anyone know what ord stands for? Is it ordinal or something else?
Look up what ord (gets a asciis integer value) and chr (turns integer values back into charcters) do. As it sits the code is just grabbing the next ascii character (a becomes b). Btw in the future you should read the official documentation before asking a question you could have easily answered yourself.