We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Strings
- Text Alignment
- Discussions
Text Alignment
Text Alignment
+ 0 comments Little to no information given. There was no parial code and no information on the logo. I'm not sure why I had a blank code screen but this needs to be fixed before you present it to anyone else.
I had to submit code for the first test case then figure out the pattern for the other test cases.
I real life I would never attempt somehting if requirement were not properly stated.I treated this like test driven development with no real information, so I had to look at the test cases to determine the expected result.
+ 0 comments #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))
+ 0 comments width = int(input()) c = "H" for i in range(width): print((c*i).rjust(width-1)+c+(c*i).ljust(width-1)) for i in range(width+1): print((c*width).rjust(width+(int((width/2)-0.5)))+(c*width).rjust(width*4)) for i in range(int((width/2)+0.5)): print(((c*(width*5)).rjust((width*5)+(int((width/2)-0.5))))) for i in range(width+1): print((c*width).rjust(width+(int((width/2)-0.5)))+(c*width).rjust(width*4)) for i in range(width): print(((c*(width-(i+1))).rjust((width*5)-1))+c+(c*(width-(i+1))))
+ 0 comments thickness = int(input()) s = "" #Top Cone for x in range(1,thickness*2,2): s += ('H'*x).center(thickness*2-1," ") + "\n" #Top Pillars for x in range(thickness+1): s += ('H'*thickness).center(thickness*2-1," ") + ('H'*thickness).center(thickness*6+1," ") + '\n' #Middle Belt for x in range(0,thickness,2): s += ('H'*thickness*5).center(thickness*5+(thickness//2)*2," ") + "\n" #Bottom Pillars for x in range(thickness+1): s += ('H'*thickness).center(thickness*2-1," ") + ('H'*thickness).center(thickness*6+1," ") + '\n' #Bottom Cone for x in range(thickness*2-1,0,-2): weight = thickness*4 s += (" "*weight)+('H'*x).center(thickness*2," ") + "\n" print(s)
+ 0 comments if __name__ == '__main__': n = int(input()) s = '' # Top cone for i in range(1,n*2,2): s = s + (i * 'H').center(n * 2 - 1 , " ") + '\n' # Top Square s1 = (n * 'H').center(n * 2 - 1 , " ") + (n * 2 + 1) * " " for i in range(n + 1): s = s + (2 * s1) + '\n' # Middle line s2 = (n * 5 * 'H').center(n * 6 - 1 , " ") for i in range(0 , n , 2): s = s + s2 + '\n' # Bottom square s3 = (n * 'H').center(n * 2 - 1 , " ") + (n * 2 + 1) * " " for i in range(n + 1): s = s + (2 * s3) + '\n' # Bottom cone for i in range(n * 2 - 1 , 0 , -2): s = s + (n * 4) * ' ' + (i * 'H').center(n * 2 - 1) + '\n' print(s)
Load more conversations
Sort 327 Discussions, By:
Please Login in order to post a comment