Program of Coded Figure Message in Python

Program of Coded Figure Message in Python. Today we will be taking a figure made of characters, spaces and then assign it to a message in the figure. This program is for medium level programmers, those have he basic knowledge of Python basic code.

Step By Step Guide for Program of Coded Figure Message in Python :

Today we will be taking a figure made of characters, spaces and then assign it to a message in the figure.

Step 1: We have developed a picture using the characters in picture variable.
Step 2: Then we are replacing the characters by the message by the use of remainder formula i.e % using this operator. Spaces are not changed they remain the similar way.

Code :

import sys
 
picture = """
 ....................................................................
 ************** * *** ** * ******************************
 ********************* ** ** * * ****************************** **
 ** ***************** ******************************
 ************* ** * **** ** ************** *
 ********* ******* **************** * *
 ******** *************************** *
 * * **** *** *************** ****** ** *
 **** * *************** *** *** *
 ****** ************* ** ** *
 ******** ************* * ** ***
 ******** ******** * *** ****
 ********* ****** * **** ** * **
********* ****** * * *** * *
 ****** ***** ** ***** *
 ***** **** * ********
 ***** **** *********
 **** ** ******* *
 *** * *
 ** * *
...................................................................."""

print('picture message, by Archit ')
print('Enter the message to show in the picture.')
mess = input('> ')
if mess == '':
    sys.exit()

 # Looping each line in picture
for line in picture.splitlines():
    # Looping over each character in a line:
    for i, bit in enumerate(line):
        if bit == ' ':
            # Printing a empty space as the mess is empty:
            print(' ', end='')
        else:
            # Printing a character from the mess where it is not empty:
            print(mess[i % len(mess)], end='')
    print() # Printing a newline.

Output :

We have given Morning as a message. Then the output is:

Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type “help”, “copyright”, “credits” or “license()” for more information.

======= RESTART: C:\Users\ARCHIT\Desktop\new python progrm\bitmap 3.py =======
picture message, by Archit
Enter the message to show in the picture.
morning

orningmorningmorningmorningmorningmorningmorningmorningmorningmornin
orningmorningm r ing or i gmorningmorningmorningmorningm
orningmorningmorningm rn ng o n ngmorningmorningmorningmorning o
or ingmorningmorning orningmorningmorningmorningmor
orningmorning or i gmor in morningmorning o
orningmor ingmorn ngmorningmorning o n
orningmo ningmorningmorningmorningmo n
o n ngmo nin morningmorningm rningm rn n
orni g orningmorningmo nin mor i
orning orningmorning or in m
orningmo ningmorningmo n ng orn
orningmo ningmorn n mor ingm
orningmor ingmor i gmor in m rn
morningmo ningmo n n mor i g
orning ornin mo ningm r
ornin morn n morningm
ornin morn ngmorning
orni gm rningmo n
orn n m
or i g
morningmorningmorningmorningmorningmorningmorningmorningmorningmorni

Conclusion:

The program is running fine.

Thank you for reading and copying the project : Program of Coded Figure Message in Python. This program is for medium level programmers and college engineering students . There is more program available, click the link below:
Python Programs Archives – CS Study

Leave a Comment

Your email address will not be published.