Python Forum
py.exe: printing ascii number 7
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
py.exe: printing ascii number 7
#1
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.
Reply
#2
print(chr(int(input('input an ascii number\nstandard 0-127\n').strip())))
Reply
#3
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()
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#4
Photo 
printing ascii number 7

print(chr(7))

[Image: attachment.php?aid=467]

Attached Files

Thumbnail(s)
   
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020