Tuesday, April 24, 2018

Animated Banner Program Python

Tags

Program: Write a Program to create an animated banner program.

Code :
import os

import time

WIDTH = 79

message = "Dishant".upper()
printedMessage = [ "","","","","","","" ]

characters = { " " : [ " ",
                       " ",
                       " ",
                       " ",
                       " ",
                       " ",
                       " " ],

               "I" : [ "*******",
                       "   *   ",
                       "   *   ",
                       "   *   ",
                       "   *   ",
                       "   *   ",
                       "*******" ],

               "H" : [ "*     *",
                       "*     *",
                       "*     *",
                       "*******",
                       "*     *",
                       "*     *",
                       "*     *" ],

               "S" : [ "*******",
                       "*      ",
                       "*      ",
                       "*******",
                       "      *",
                       "      *",
                       "*******" ],

               "D" : [ "********",
                       "*      *",
                       "*      *",
                       "*      *",
                       "*      *",
                       "*      *",
                       "********" ],

               "N" : [ "*      *",
                       "**     *",
                       "* *    *",
                       "*  *   *",
                       "*    * *",
                       "*     **",
                       "*      *" ],

               "T" : [ "********",
                       "    *   ",
                       "    *   ",
                       "    *   ",
                       "    *   ",
                       "    *   ",
                       "    *   " ],


               "A" : [ "*******",
                       "*     *",
                       "*     *",
                       "*******",
                       "*     *",
                       "*     *",
                       "*     *" ]


               }

for row in range(7):
    for char in message:
        printedMessage[row] += (str(characters[char][row]) + "  ")

offset = WIDTH
while True:
    os.system("cls")
    for row in range(7):
        print(" " * offset + printedMessage[row][max(0,offset*-1):WIDTH - offset])
    offset -=1    if offset <= ((len(message)+2)*6) * -1:
        offset = WIDTH
    time.sleep(0.05)
 
 
Output: