<jupyter_start><jupyter_text>练习一：自定义reverse函数<jupyter_code>def myreverse(s):
    r = str()
    r = s[::-1]
    return r

s = [1,2,3,4,5]
print(myreverse(s))<jupyter_output>[5, 4, 3, 2, 1]<jupyter_text>练习二：写函数，根据给定符号和行数，打印相应直角三角形，等腰三角形及其他形式的三角形。<jupyter_code>def triangle(s,l):
    for i in range(1,l+1):
        print(s*i)
    print('-'*20)
    
    t = l
    for i in range(1,l+1):
        print(' '*t,s*(2*i-1))
        t -= 1
    print('-'*20)
        
    for i in range(1,l+1):
        print(' '*i,s*(2*i-1))
        
s = '6'
l = 6
triangle(s,l)<jupyter_output>6
66
666
6666
66666
666666
--------------------
       6
      666
     66666
    6666666
   666666666
  66666666666
--------------------
  6
   666
    66666
     6666666
      666666666
       66666666666<jupyter_text>练习三：将任务4中的英语名词单数变复数的函数，尽可能的考虑多种情况，重新进行实现。<jupyter_code>def danci(word):
    if word.endswith('x') or word.endswith('o'):
        print(word+"es")
    elif word.endswith('ch') or word.endswith('sh'):
        print(word+"es")
    else :
        print(word+"s")
        
word=input("请输入一个英文单词：")
danci(word)<jupyter_output>请输入一个英文单词：box
boxes
{'fraction_non_alphanumeric': 0.19111111111111112, 'fraction_numerical': 0.10844444444444444, 'mean_word_length': 2.432926829268293, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 6, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '305925', 'license': 'MIT', 'n_tokens_mistral': 616, 'n_tokens_neox': 572, 'n_words': 77, 'path': 'chapter2/homework/computer/4-19/201611680560.ipynb', 'repo_name': 'hpishacker/python_tutorial', 'size': '1125'}