🔒 Closed Python3: print integers as glyphs

Status
Not open for further replies.

nnivx

Enthusiast
Share ko lang yung ginawa ko a while ago para sa assignment ng kaibigan ko. This code will print positive integers as a 3-line glyph:
Code:
# Sample output for 5674:
#  _   _   _
# |_  |_    | |_|
#  _| |_|   |   |

s = input('Enter Number: ')
STAMP = ' _ |_||_|'
NUM   = ['4', '13467', '38', '36', '167', '56', '5', '3467', '', '6']

# data
buf = []
for nc in s:
    buf.append(''.join([STAMP[x] if (str(x) not in NUM[int(nc)]) else ' ' for x in range(0, 9)]))
   
# print per line
for x in range(0, 9, 3):
    print(' '.join([c[x:x+3] for c in buf]))


Disclaimer: this is just how I did it, not sure kung may mas ez pa. Kung meron kayong better code or other ideas, share niyo rin :>

Spoiler contents are visible only to Established Members.
 
405043534677147659.png 402866237853401100.png parang nagbabasa ako ng alien language
 
Status
Not open for further replies.

About this Thread

  • 8
    Replies
  • 836
    Views
  • 6
    Participants
Last reply from:
ralph_acero

Trending Topics

Online now

Members online
1,142
Guests online
1,362
Total visitors
2,504

Forum statistics

Threads
2,273,442
Posts
28,949,527
Members
1,235,747
Latest member
_usteng_
Back
Top