Text Alignment

Sort by

recency

|

497 Discussions

|

  • + 0 comments

    f name =="main": width = int(input()) actual_fig_width = 6*width

    #left arrow
    for i in range(width):
        print(('H'*(2*i+1)).center(2*width))
    
    #top pillars
    for i in range(width+1):
        print(('H'*width).center(2*width) + (('H'*width).rjust(actual_fig_width - 3*width + width//2)))
    
    #middle horizontal pillar
    for i in range(width//2 +1):
        print(('H'*(width*5)).center(actual_fig_width))
    
    #bottom pillars
    for i in range(width+1):
        print(('H'*width).center(2*width) + (('H'*width).rjust(actual_fig_width - 3*width + width//2)))
    
    #bottom arrow
    for i in range(width-1,-1,-1):
        print((' '*2*width).center(actual_fig_width - 2*width) + ('H'*(2*i+1)).center(2*width))
    
  • + 0 comments

    Python Strings really tests your understanding of string manipulation and formatting using Python. It’s a great way to practice with functions, Gurubhai 247

  • + 0 comments

    For Python3 Platform

    #Replace all ______ with rjust, ljust or center. 
    
    thickness = int(input()) #This must be an odd number
    c = 'H'
    
    #Top Cone
    for i in range(thickness):
        print((c*i).rjust(thickness-1)+c+(c*i).ljust(thickness-1))
    
    #Top Pillars
    for i in range(thickness+1):
        print((c*thickness).center(thickness*2)+(c*thickness).center(thickness*6))
    
    #Middle Belt
    for i in range((thickness+1)//2):
        print((c*thickness*5).center(thickness*6))    
    
    #Bottom Pillars
    for i in range(thickness+1):
        print((c*thickness).center(thickness*2)+(c*thickness).center(thickness*6))    
    
    #Bottom Cone
    for i in range(thickness):
        print(((c*(thickness-i-1)).rjust(thickness)+c+(c*(thickness-i-1)).ljust(thickness)).rjust(thickness*6))
    
  • + 1 comment
    if __name__ =="__main__":
        width = int(input())
        actual_fig_width = 6*width
    
        #left arrow
        for i in range(width):
            print(('H'*(2*i+1)).center(2*width))
    
        #top pillars
        for i in range(width+1):
            print(('H'*width).center(2*width) + (('H'*width).rjust(actual_fig_width - 3*width + width//2)))
    
        #middle horizontal pillar
        for i in range(width//2 +1):
            print(('H'*(width*5)).center(actual_fig_width))
    
        #bottom pillars
        for i in range(width+1):
            print(('H'*width).center(2*width) + (('H'*width).rjust(actual_fig_width - 3*width + width//2)))
    
        #bottom arrow
        for i in range(width-1,-1,-1):
            print((' '*2*width).center(actual_fig_width - 2*width) + ('H'*(2*i+1)).center(2*width))
    
  • + 0 comments

    Here is Text Alignment python solution - https://programmingoneonone.com/hackerrank-text-alignment-problem-solution-in-python.html