Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

print animation python

# importing the necessary packages
import time
import sys
import os
  
# Function for implementing the loading animation
def load_animation():
  
    # String to be displayed when the application is loading
    load_str = "starting your console application..."
    ls_len = len(load_str)
  
  
    # String for creating the rotating line
    animation = "|/-"
    anicount = 0
      
    # used to keep the track of
    # the duration of animation
    counttime = 0        
      
    # pointer for travelling the loading string
    i = 0                     
  
    while (counttime != 100):
          
        # used to change the animation speed
        # smaller the value, faster will be the animation
        time.sleep(0.075) 
                              
        # converting the string to list
        # as string is immutable
        load_str_list = list(load_str) 
          
        # x->obtaining the ASCII code
        x = ord(load_str_list[i])
          
        # y->for storing altered ASCII code
        y = 0                             
  
        # if the character is "." or " ", keep it unaltered
        # switch uppercase to lowercase and vice-versa 
        if x != 32 and x != 46:             
            if x>90:
                y = x-32
            else:
                y = x + 32
            load_str_list[i]= chr(y)
          
        # for storing the resultant string
        res =''             
        for j in range(ls_len):
            res = res + load_str_list[j]
              
        # displaying the resultant string
        sys.stdout.write("
"+res + animation[anicount])
        sys.stdout.flush()
  
        # Assigning loading string
        # to the resultant string
        load_str = res
  
          
        anicount = (anicount + 1)% 4
        i =(i + 1)% ls_len
        counttime = counttime + 1
      
    # for windows OS
    if os.name =="nt":
        os.system("cls")
          
    # for linux / Mac OS
    else:
        os.system("clear")
  
# Driver program
if __name__ == '__main__': 
    load_animation()
  
    # Your desired code continues from here 
    # s = input("Enter your name: ")
    s ="David"
    sys.stdout.write("Hello "+str(s)+"
")
Comment

PREVIOUS NEXT
Code Example
Python :: realtime output subprocess 
Python :: how to make tkinter look better 
Python :: check if number is prime python 
Python :: pass arguments with apply 
Python :: add 1 to all columns in numpy array 
Python :: add values to tuple python 
Python :: merge two columns name in one header pandas 
Python :: python package structure 
Python :: python check if number in string 
Python :: how to download from youtube in discord.py 
Python :: keras normalize 
Python :: new line print python 
Python :: flat numpy array 
Python :: selenium ways of finding 
Python :: use gpu for python code in vscode 
Python :: turtle example 
Python :: concatenation array 
Python :: seaborn library in python 
Python :: how to append in dictionary in python 
Python :: check all true python 
Python :: django override delete 
Python :: how ro have a incresing variable in python 
Python :: find the last point of line geopanda 
Python :: get coordinates in xarray 
Python :: freecodecamp python 
Python :: twitter api tutorial python 
Python :: pyinstaller pymssql 
Python :: send dm to user discord.py 
Python :: django cleanup 
Python :: how to get a specific field in django 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =