How does a computer, which can only work
with binary numbers, handle letters (characters)? It will probably not
surprise you that this is done by representing each of these characters as
a binary number. The first developers of computer systems came up with
several ways to represent characters as binary numbers.
But first of all, what is a character? Characters are entities that you
print on a sheet, which usually consist of letters (a, b, c, ...), numbers
(0, 1, 2, ...), and punctuation marks (period, comma, semicolon, ...).
However, there are characters that cannot be printed, such as a carriage
return or tab, along
with other characters that go back to the time of the very first computer
systems such as form feed.
The first standardized way to present characters in a computer as binary
numbers was the American Standard Code
for Information Interchange, or ASCII for short, developed in
1963. The ASCII table shows how each of the natural numbers from 0 to 255
can be converted to its corresponding character, and vice versa. For
example, the character "A" is
represented by the number 65, while the number 97 is the character "a".
Luckily, you do not have to know this table by heart in order to work with
the ASCII representation of characters. In Python, you can use the
following two built-in functions:
chr(n) prints the character that corresponds with the number n in the ASCII table. In that way chr(97) returns the string "a".
ord(c) prints the ASCII value of the character c . For example: ord("A") returns the value 65 .
No input.
Write out a portion of the ASCII table by writing a line for each number from 33 to 126, showing the number, followed by a tab and the character that corresponds to this number in the ASCII table. This part of the ASCII table only contains printable characters.
Output:
33 !
34 "
35 #
...
124 |
125 }
126 ~