Python Forum

Full Version: py.exe: printing ascii number 7
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was messing around in python with ascii,
And I found something I think is interesting.
This:
quitfunc = 'r'
while(quitfunc == 'r'):
    ascnum = input('input an ascii number\nstandard 0-127\n')
    ascnum = int(ascnum)
    asctext = str(chr(ascnum))
    print(asctext)
    quitfunc = input("type 'r' to redo\n")
and that if you input 7,
it makes a "beep" sound despite it saying
print(asctext)
another weird thing about this is that it doesn't work with shell,
only with py.exe.
I wanna know why this happens.
I also wanna know if this works on other operating systems,
or other versions of python(I was using 3.6.3)
sadly, I couldn't find a "beep" sound that accurately sounded like
the one in py.exe, so your just gonna have to take my word for it.
print(chr(int(input('input an ascii number\nstandard 0-127\n').strip())))
You should look at this table: http://www.asciitable.com/
0x7 is BEL.

To see what's possible with ascii, you can test this tiny program:

import time
from urllib.request import urlopen


def get():
    baseurl = 'https://vt100.net/animation'
    files = [f'{baseurl}/xmas{n}.txt' for n in range(10)]
    for file in files:
        yield urlopen(file)


def draw():
    for animation in get():
        for char in animation:
            print(char.decode(errors='ignore'), end='', flush=True)
            time.sleep(0.05)


if __name__ == '__main__':
    draw()
printing ascii number 7

print(chr(7))

[Image: attachment.php?aid=467]