Python3.3 implements the multiplication representation

  • 2020-04-02 13:25:02
  • OfStack


from StringHelper  import PadLeft 
 for x in range(1,10):    
     for y in  range (1,x+1):        
         endflag='  |  n' if x==y else '  |  '
         print(y,'*',x,'=',PadLeft( str(x*y),2,'  '),end=endflag)

StringHelper. Py


# -*- coding: utf8 -*-
'''
 Extended to C# In the String.PadLeft
'''
def PadLeft(str, num, padstr):
    stringlength = len(str)
    n = num - stringlength
    if n >= 0:
        str = padstr*n + str
    return str


Effect:
< img border = 0 id = theimg onclick = window. The open this. (SRC) SRC = "/ / img.jbzj.com/file_images/article/201402/20140207094114.jpg? 20141794410 ">  


Related articles: