0

hi guys, i need to print the ASCII tabel using only the control staments; the unprintable characters need to be represented by the ASCCII name or a. any ideas that may help?
is the ASCII table define in paython?

6
Contributors
12
Replies
13
Views
9 Years
Discussion Span
Last Post by Ryanvh
Featured Replies
  • 1

    There is a slight flaw in ZZucker's post, but the OP should have reason this out for themselves. Read More

0

The simplest way is to use the dictionary:

# print the control characters of an ASCII table ...

controls_dic = {
1: 'SOH', 2: 'STX', 3: 'ETX', 4: 'EOT', 5: 'ENQ', 6: 'ACK', 7: 'BEL',
8: 'BS', 9: 'HT', 10: 'LF', 11: 'VT', 12: 'FF', 13: 'CR', 14: 'SO',
15: 'SI', 16: 'DLE', 17: 'DC1', 18: 'DC2', 19: 'DC3', 20: 'DC4', 21: 'NAK',
22: 'SYN', 23: 'ETB', 24: 'CAN', 25: 'EM', 26: 'SUB', 27: 'ESC', 28: 'FS',
29: 'GS', 30: 'RS', 31: 'US'}

for key in range(1, 32):
    print key, controls_dic[key]
0

So I need to print an ASCII table of all characters with values 0 to 127 using char(x). The table needs to be in columns of 16.

How do I do that?

0

...

>>>for i in range(0,127):
print i


and that will give me a whole print out of all the numbers... but what is an ASCII table and how do I get it in columns of 16? Thanks for your help so far

0

Here is one example:

# print 0 to 127 in a table of 16 columna

n = 1
for k in range(0, 128):
    if n % 17:
        print "%4d" % k,
    else:
        print
    n += 1
1

There is a slight flaw in ZZucker's post, but the OP should have reason this out for themselves.

Votes + Comments
good eyes
0

That gives me the numbers in a column of 16, that's good... but how do you get it to display the ASCII table that way?

nevermind.. lol thanks for the link!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.