Loading...
Searching...
No Matches
phyduino/04_communication/ascii_table/main.py

Prints the printable ASCII characters, 33 ("!") to 126 ("~"), each with its value in decimal, hexadecimal, octal and binary, then stops.

Output
ASCII Table ~ Character Map
!, dec: 33, hex: 21, oct: 41, bin: 100001
", dec: 34, hex: 22, oct: 42, bin: 100010
...
# Prints the printable ASCII characters, 33 ("!") to 126 ("~"), each with its
# value in decimal, hexadecimal, octal and binary, then stops.
print("ASCII Table ~ Character Map")
for code in range(33, 127): # 33 up to 126; range() stops before its second number
# chr() gives the character for a code. %d is decimal, %x hexadecimal and
# %o octal; bin() gives "0b100001", and [2:] drops the "0b".
print("%s, dec: %d, hex: %x, oct: %o, bin: %s" % (chr(code), code, code, code, bin(code)[2:]))