Skip to main content

Print Your Name Using Python || write a program to print your name in pattern - Creation Code

 Printing Your Name Using a Python Programm

In this post, we will write a program where we will take the user's name as input and in output, we will show them the pattern of their name. It will be really fun so let's jump into the code without wasting any time

from random import randrange

#Function print_text_in_symbol
def print_text_in_symbol(text_input, symbol_char = 'X', symbol_bg = '-', inline = False):
    
    #Lists for the formation of the letters
    a = ['000000000000',
         '000111111000',
         '011000000110',
         '011000000110',
         '011111111110',
         '011000000110',
         '011000000110',
         '011000000110']
    
    b = ['000000000000',
         '011111111000',
         '011000000110',
         '011000000110',
         '011111111000',
         '011000000110',
         '011000000110',
         '011111111000']
    
    c = ['000000000000',
         '000111111000',
         '011000000110',
         '011000000000',
         '011000000000',
         '011000000000',
         '011000000110',
         '000111111000']
    
    d = ['000000000000',
         '011111111000',
         '011000000110',
         '011000000110',
         '011000000110',
         '011000000110',
         '011000000110',
         '011111111000']
    
    e = ['000000000000',
         '011111111110',
         '011000000000',
         '011000000000',
         '011111111100',
         '011000000000',
         '011000000000',
         '011111111110']
    
    f = ['000000000000',
         '011111111110',
         '011000000000',
         '011000000000',
         '011111111100',
         '011000000000',
         '011000000000',
         '011000000000']
    
    g = ['000000000000',
         '000111111000',
         '011000000110',
         '011000000000',
         '011000000000',
         '011000011110',
         '011000000110',
         '000111111000']
    
    h = ['000000000000',
         '011000000110',
         '011000000110',
         '011000000110',
         '011111111110',
         '011000000110',
         '011000000110',
         '011000000110']
    
    i = ['000000000000',
         '000111111000',
         '000001100000',
         '000001100000',
         '000001100000',
         '000001100000',
         '000001100000',
         '000111111000']
         
    j = ['000000000000',
         '000001111110',
         '000000011000',
         '000000011000',
         '000000011000',
         '000000011000',
         '011000011000',
         '000111100000']
    
    k = ['000000000000',
         '011000000110',
         '011000011000',
         '011001100000',
         '011110000000',
         '011001100000',
         '011000011000',
         '011000000110']
    
    l = ['000000000000',
         '011000000000',
         '011000000000',
         '011000000000',
         '011000000000',
         '011000000000',
         '011000000000',
         '011111111110']
    
    m = ['000000000000',
         '011000000110',
         '011110011110',
         '011001100110',
         '011001100110',
         '011000000110',
         '011000000110',
         '011000000110']
    
    n = ['000000000000',
         '011000000110',
         '011000000110',
         '011110000110',
         '011001100110',
         '011000011110',
         '011000000110',
         '011000000110']
    
    o = ['000000000000',
         '000111111000',
         '011000000110',
         '011000000110',
         '011000000110',
         '011000000110',
         '011000000110',
         '000111111000']
    
    p = ['000000000000',
         '011111111000',
         '011000000110',
         '011000000110',
         '011111111000',
         '011000000000',
         '011000000000',
         '011000000000']
    
    q = ['000000000000',
         '000111111000',
         '011000000110',
         '011000000110',
         '011000000110',
         '011001100110',
         '011000011000',
         '000111100110']
    
    r = ['000000000000',
         '011111111000',
         '011000000110',
         '011000000110',
         '011111111000',
         '011001100000',
         '011000011000',
         '011000000110']
    
    s = ['000000000000',
         '000111111110',
         '011000000000',
         '011000000000',
         '000111111000',
         '000000000110',
         '000000000110',
         '011111111000']
    
    t = ['000000000000',
         '011111111110',
         '000001100000',
         '000001100000',
         '000001100000',
         '000001100000',
         '000001100000',
         '000001100000']
    
    u = ['000000000000',
         '011000000110',
         '011000000110',
         '011000000110',
         '011000000110',
         '011000000110',
         '011000000110',
         '000111111000']
    
    v = ['000000000000',
         '011000000110',
         '011000000110',
         '011000000110',
         '011000000110',
         '000110011000',
         '000110011000',
         '000001100000']
    
    w = ['000000000000',
         '011000000110',
         '011000000110',
         '011000000110',
         '011001100110',
         '011001100110',
         '011001100110',
         '000110011000']
    
    x = ['000000000000',
         '011000000110',
         '011000000110',
         '000110011000',
         '000001100000',
         '000110011000',
         '011000000110',
         '011000000110']
         
    y = ['000000000000',
         '011000000110',
         '011000000110',
         '000110011000',
         '000001100000',
         '000001100000',
         '000001100000',
         '000001100000']
         
    z = ['000000000000',
         '011111111110',
         '000000000110',
         '000000011000',
         '000001100000',
         '000110000000',
         '011000000000',
         '011111111110']
         
    sp = ['000000000000',
          '000000000000',
          '000000000000',
          '000000000000',
          '000000000000',
          '000000000000',
          '000000000000',
          '000000000000']
    
    n0 = ['000000000000',
          '000111111000',
          '011000000110',
          '011000011110',
          '011001100110',
          '011110000110',
          '011000000110',
          '000111111000']
    
    n1 = ['000000000000',
          '000001100000',
          '000111100000',
          '000001100000',
          '000001100000',
          '000001100000',
          '000001100000',
          '000111111000']
          
    n2 = ['000000000000',
          '000111111000',
          '011000000110',
          '000000000110',
          '000000011000',
          '000001100000',
          '000110000000',
          '011111111110']
    
    n3 = ['000000000000',
          '011111111110',
          '000000011000',
          '000001100000',
          '000000011000',
          '000000000110',
          '011000000110',
          '000111111000']
    
    n4 = ['000000000000',
          '000000011000',
          '000001111000',
          '000110011000',
          '011000011000',
          '011111111110',
          '000000011000',
          '000000011000']
                      
    n5 = ['000000000000',
          '011111111110',
          '011000000000',
          '011111111000',
          '000000000110',
          '000000000110',
          '011000000110',
          '000111111000']
                      
    n6 = ['000000000000',
          '000001111000',
          '000110000000',
          '011000000000',
          '011111111000',
          '011000000110',
          '011000000110',
          '000111111000']
                      
    n7 = ['000000000000',
          '011111111110',
          '000000000110',
          '000000011000',
          '000001100000',
          '000110000000',
          '000110000000',
          '000110000000']
                      
    n8 = ['000000000000',
          '000111111000',
          '011000000110',
          '011000000110',
          '000111111000',
          '011000000110',
          '011000000110',
          '000111111000']
                      
    n9 = ['000000000000',
          '000111111000',
          '011000000110',
          '011000000110',
          '000111111110',
          '000000000110',
          '000000011000',
          '000111100000']
    
    s0 = ['000000000000',
          '000111111000',
          '011000000110',
          '000000000110',
          '000000011000',
          '000001100000',
          '000000000000',
          '000001100000']
    
    s1 = ['000000000000',
          '000001100000',
          '000001100000',
          '000001100000',
          '000001100000',
          '000001100000',
          '000000000000',
          '000001100000']      
    
    s2 = ['000000000000',
          '000000000000',
          '000000000000',
          '000000000000',
          '000000000000',
          '000000000000',
          '000001100000',
          '000001100000']                  
    
    s3 = ['000000000000',
          '000000000000',
          '000000000000',
          '000000000000',
          '000000000000',
          '000000000000',
          '000000000000',
          '000001100000']
    
    s4 = ['000000000000',
          '000000000000',
          '000000000000',
          '000000000000',
          '001111111100',
          '000000000000',
          '000000000000',
          '000000000000']
    
    s5 = ['000000000000',
          '000000000000',
          '000001100000',
          '000001100000',
          '011111111110',
          '000001100000',
          '000001100000',
          '000000000000']
          
    
    ascii_alph = [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z,
                 sp, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9,
                 s0, s1, s2, s3, s4, s5, s5]
    
    #---END------Lists for the formation of the letters----------------
    
    res = ''
    dont_use =''
    alph = 'abcdefghijklmnopqrstuvwxyz 0123456789?!,.-+'
    text_error = 'Print Successful.\n Your text :'
    
    text_input = text_input.lower()
    your_text = text_input
    
    #-----------Processing errors in text_input-----------------
    # 1. If nothing is entered
    if text_input == '':
        text_input = 'none text'
        your_text = "You don't input text."
        
    # 2. Checking for a character in the alphabet
    try:
        for char in text_input.lower():
            # 3. if there is no character in the alphabet function returns an error(ValueError)    
            alph.index(char)
          
    #------error Processing(ValueError)---- 
    except ValueError:
        text_error = '''
Error input. 
1. Use A-Z a-z, 0-9, ?!,.-+, for your input.
Your text: '''
        # changing text_input
        text_input = 'error'
    #---END---error Processing(ValueError)------   
    
    finally:
        # Outputs the generated string
        print(text_error+your_text+dont_use)
        
        if inline:
            res = ''
            print_res = ''
            for i in range(0, 8):
                for char in text_input:
                    ch_ascii = ascii_alph[alph.index(char)]
                    res += ch_ascii[i]
                res += '\n'
            for char in res:
                if char == '0':
                    print_res += symbol_bg
                elif char == '1':    
                    print_res += symbol_char
                elif char == '\n':
                    print_res += '\n'
            print(print_res)    
        else:    
            for char in text_input:
                ch_ascii = ascii_alph[alph.index(char)]
                for i in ch_ascii:
                    for t in i:
                        for char in t:
                            if char == '0':
                                res += symbol_bg
                            elif char == '1':    
                                res += symbol_char
                    print(res)
                    res = ''
    #---END-----Processing errors in input-----------------
    
#-----END---------Function print_text_in_symbol------------  
    
#---Set for select characters-------------------------------
ch ='XO#@'
ch_bg = '.`'
#---Random selection of a set of characters----------------
rand_ch = ch[randrange(len(ch))]
rand_bg = ch_bg[randrange(len(ch_bg))]


#User input----------------------------------------
text_input = input()

print("Please leave a like if you enjoyed!\n")

# print("print in a horizontal line".upper())
#print_text_in_symbol(text_input, rand_ch, rand_bg, inline = True)

print("print in a vertical line".upper())
print_text_in_symbol(text_input, rand_ch, rand_bg, inline = False)

Output:



Follow my socials:

Youtube:https://www.youtube.com/channel/UCU1qNFntn7dCi9uqyvrGKOg

Instagram: https://www.instagram.com/python.math/

Twitter:https://twitter.com/Pritish369


For any question or coding discussion, you can join my discord or telegram:

Discord:https://discord.gg/be7MmSuV

Telegram:https://t.me/Python_Math_Community

Comments

Popular posts from this blog

Create Ping Pong Game in Python

  Ping Pong Game: Table tennis , also known as  ping-pong  and  whiff-whaff , is a sport in which two or four players hit a lightweight ball, also known as the ping-pong ball, back and forth across a table using small rackets. The game takes place on a hard table divided by a net. Except for the initial serve, the rules are generally as follows: players must allow a ball played toward them to bounce once on their side of the table and must return it so that it bounces on the opposite side at least once. A point is scored when a player fails to return the ball within the rules. Play is fast and demands quick reactions. Spinning the ball alters its trajectory and limits an opponent's options, giving the hitter a great advantage. We can make it using pygame but I keep it more simple we will create this game using only the turtle module so let's drive into the code without wasting any time Code: # Import required library import turtle # Create screen sc = turtle . Screen () sc .

Draw Minecraft Charater in Python

  Minecraft  is a  sandbox video game  developed by the Swedish video game developer  Mojang Studios . The game was created by  Markus "Notch" Persson  in the  Java programming language . Following several early private testing versions, it was first made public in May 2009 before fully releasing in November 2011, with  Jens Bergensten  then taking over development.  Minecraft  has since been ported to several other platforms and is the  best-selling video game of all time , with over 238 million copies sold and nearly 140 million  monthly active users  as of 2021 . We gonna build a character of Minecraft using our creativity and coding skills so let's drive into the code: Code: import turtle as t def eye ( r , a ):     t . fillcolor ( 'brown' )     t . begin_fill ()     t . circle ( r , a )     t . end_fill () t . begin_fill () t . fillcolor ( '#8a00e6' ) t . penup () t . goto ( 0 ,- 50 ) t . pendown () t . right ( 90 ) t . f

How To Draw BMW Logo - In Python

 I know I don't need to introduce BMW as it is a very popular luxury car. Today we gonna draw the BMW logo in python. I know that you can draw it using a pencil and other tools like AutoCAD etc. But we are programmers we talk with computers so let's tell our computer to draw this logo for use with the help of python. Module The only module we will use is that turtle Code: import turtle as t t.begin_fill() t.fillcolor( '#008ac9' ) for i in range ( 50 ):     t.forward( 4 )     t.left( 2 ) t.right(- 80 ) t.forward( 116 ) t.right(- 90 ) t.forward( 132 ) t.end_fill() t.penup() t.pendown() t.right( 90 ) for i in range ( 50 ):     t.forward( 4 )     t.left(- 2 ) t.right( 80 ) t.forward( 116 ) t.forward(- 116 ) t.right( 90 ) t.begin_fill() t.fillcolor( '#008ac9' ) for j in range ( 45 ):     t.forward(- 4 )     t.left(- 2 ) t.right(- 90 ) t.forward( 116 ) t.end_fill() t.right( 180 ) t.forward( 116 ) t.right( 90 ) for i in range ( 47 ):     t.forward( 4 )     t.