Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
chr in Python
#6
Ascii table shows how numbers are stored in the memory

[Image: asciifull.gif]

chr(number) function allows you to convert number into character. Here's example:

hello_world_numbers = [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]
print("".join(chr(n) for n in hello_world_numbers))
Output:
hello world
If that doesn't make much sense you can take print 1 chr() at once and get similar result like:
print(   
    chr(104),
    chr(101),
    chr(108),
    chr(108),
    chr(111),
    chr(32),
    chr(119),
    chr(111),
    chr(114),
    chr(108),
    chr(100)
    )
Output:
h e l l o w o r l d
To get the block number you can use division, math.floor function and add 65 as suggested in previous post, to get the floor number you can use "modulo" operation.

Here's how math.floor can be used:

from math import floor
print(floor(10.21312312))
Output:
10
Reply


Messages In This Thread
chr in Python - by DarkCraftPlayz - May-14-2019, 01:01 PM
RE: chr in Python - by perfringo - May-14-2019, 01:18 PM
RE: chr in Python - by DarkCraftPlayz - May-14-2019, 01:34 PM
RE: chr in Python - by perfringo - May-14-2019, 01:40 PM
RE: chr in Python - by DarkCraftPlayz - May-14-2019, 04:01 PM
RE: chr in Python - by SheeppOSU - May-14-2019, 01:20 PM
RE: chr in Python - by michalmonday - May-14-2019, 01:40 PM
RE: chr in Python - by perfringo - May-14-2019, 08:35 PM
RE: chr in Python - by DarkCraftPlayz - May-15-2019, 12:20 AM

Forum Jump:

User Panel Messages

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