In [ ]:
def reverse (s):
    print(s[len(s)-1::-1])
s=str(input("plz enter a string"))
reverse(s)

In [2]:
def triangle (x):
    for i in range (x): 
        if i<x-1:
            print('|'+' '*i+'\\')
        elif i==x-1:  print('|'+'_'*i+'\\')
    print(' ')
    for i in range (x):
        if i<x-1:
            print(' '*(x-i)+'/'+' '*(2*i)+'\\')
        elif i==x-1:
            print(' '+'/'+'_'*(i+x-1)+'\\')
    
x=int(input("plz enter the height of the triangle\n"))
triangle(x)


plz enter the height of the triangle
4
|\
| \
|  \
|___\
 
    /\
   /  \
  /    \
 /______\

In [14]:
def change(word):
    print('The plurality of the noun is  ',end='')
    if word.endswith('ch') or word.endswith('sh'):
        print(word+'es')
    elif word.endswith('x') or word.endswith('s') or word.endswith('es'):
        print(word+'es')
    elif word.endswith('f'):
        print(word[:len(word)-1:]+'ves')
    elif word.endswith('y'):
        print(word[:len(word)-1:]+'ies')
    else: print(word+'s')
        
word=str(input("plz enter a countable noun\n"))
change(word)


plz enter a countable noun
scarf
The plurality of the noun is  scarves

In [ ]:
def trapezoid (x,y,h):
    d=h-1
    for i in range(h):
        if i==0:
            print(' '*(d-i)+'/'+'-'*x+'\\'+' '*(d-i))
        elif i<h-1:
            print(' '*(d-i)+'/'+' '*(x+2*(i))+'\\'+' '*(d-i))
        elif i==h-1:
            print(' '*(d-i)+'/'+'_'*(2*i+x)+'\\')
x=int(input('请输入梯形的上底长'))
h=int(input('请输入梯形的高'))
print('由于技术不娴熟,梯形的底由前两个输入值计算得出\n')
trapezoid(x,y,h)

In [18]:
def rhombus (x):
    for i in range (x):
            print(' '*(x-i)+'/'+' '*(2*i)+'\\')
    for i in range(x-1,-1,-1):
        print(' '*(x-i)+'\\'+' '*(2*(i))+'/')
x=int(input('请输入菱形的边长  '))
rhombus(x)


请输入菱形的边长  3
   /\
  /  \
 /    \
 \    /
  \  /
   \/

In [21]:
def inverted(x):
    for i in range(len(x)*2,0,-1):
        if i == 1:
            print(' '*(len(x)*2-1) +x[0])
        elif i%2 == 1:
            print(' '*(len(x)*2-i) + x[:i//2] + x[i//2] + x[i//2-1::-1])
        else:
            print(' '*(len(x)*2-i) + x[:i//2] + x[i//2-1::-1])

def main():
    word = '赏花归去马如飞'
    inverted (word)
    

if __name__ == '__main__':
    main()


赏花归去马如飞飞如马去归花赏
 赏花归去马如飞如马去归花赏
  赏花归去马如如马去归花赏
   赏花归去马如马去归花赏
    赏花归去马马去归花赏
     赏花归去马去归花赏
      赏花归去去归花赏
       赏花归去归花赏
        赏花归归花赏
         赏花归花赏
          赏花花赏
           赏花赏
            赏赏
             赏