如何使用python基础编程语言来解决下面那两道题?

三张图为一道题,第一张图片是题目要求,第二张图片是我打完一半的内容,第三张图片是这道题所需要输出的答案。求详细步骤和每一步骤这样录入的原因!非常感谢!

第1个回答  2019-05-21
def remove_short_synonyms(dic):
    for i in dic:
        for n in range(len(dic[i])):
            if len(dic[i][n]) < 8:
                dic[i][n] = ''
        while '' in dic[i]:
            dic[i].remove('')


def print_dict_in_key_order(dic):
    order = [i for i in dic]
    order.sort()
    for k in order:
        print(k, ':', sorted(dic[k]))


synonyms_dict = {'look': ['gaze', 'see', 'glance', 'watch', 'perusr'],
                 'put': ['place', 'set', 'attach', 'keep', 'save', 'set aside', 'effect',
                         'achieve', 'do', 'build'],
                 'beautiful': ['pretty', 'lovely', 'handsome', 'dazzling', 'splendid',
                               'magnificent'],
                 'slow': ['unhurried', 'gradual', 'leisurely', 'late', 'behind', 'tedious', 'slack'],
                 'danderous': ['perilous', 'hazardous', 'uncertain']}
remove_short_synonyms(synonyms_dict)
print('1.')
print_dict_in_key_order(synonyms_dict)
print()
synonyms_dict = {'come': ['approach', 'advance', 'near', 'arrive', 'reach'],
                 'show': ['display', 'exhibit', 'present', 'note', 'point to', 'indicate',
                          'explain', 'reveal', 'prove', 'demonstrate', 'expose'],
                 'good': ['excellent', 'fine', 'superior', 'wonderful', 'grand', 'superb', 'edifying'],
                 'bad': ['evil', 'immoral', 'wicked', 'rotten', 'contaminated', 'spoiled',
                         'defective', 'substandard', 'faulty', 'improper', 'inappropriate']}
remove_short_synonyms(synonyms_dict)
print('2.')
print_dict_in_key_order(synonyms_dict)
print()

本回答被提问者采纳
相似回答