Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
chr in Python
#9
(May-14-2019, 08:35 PM)perfringo Wrote: Following is not using chr(), so I am not doing your homework :-), but this one way of handling problem of 'multiples of 5':

>>> blocks = 'ABCDEFGHIJ'
>>> floors = '01234'
>>> for customer in [0, 3, 5, 7]:
...     block, floor = divmod(max(customer - 1, 0), 5)
...     print(f'Block {blocks[block]} Floor {floors[floor]}')
... 
Block A Floor 0
Block A Floor 2
Block A Floor 4
Block B Floor 1

Wow, that code gives me some ideas about what I need to learn next on Python.

But I think I finally figured out the logic.
It will be:

a = int(input())
b = a - 1
print (chr((b//5) + 64))
I havent tried it in a computer yet but I think it will work.

Thanks you guys for all your help :D
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