NP67. 遍历字典
描述
输入描述
无输出描述
按题目描述进行输出即可(注意前后两个输出部分需以一个空行进行分隔)。Python 解法, 执行用时: 10ms, 内存消耗: 2844KB, 提交时间: 2022-06-26
operators_dict = { '<': 'less than', '==': 'equal' } print ('Here is the original dict:') for k in sorted(operators_dict.keys()): print ('Operator %s means %s.' %(k,operators_dict[k])) operators_dict['>'] = 'greater than' print ('') print ('The dict was changed to:') for k in sorted(operators_dict.keys()): print ('Operator %s means %s.' %(k,operators_dict[k]))
Python 解法, 执行用时: 10ms, 内存消耗: 2848KB, 提交时间: 2022-07-18
operators_dict = {'<': 'less than','==': 'equal'} print('Here is the original dict:') for i in sorted(operators_dict.keys()): print('Operator %s means %s.' %(i, operators_dict[i])) operators_dict['>'] = 'greater than' print ('') print ('The dict was changed to:') for i in sorted(operators_dict.keys()): print ('Operator %s means %s.' %(i,operators_dict[i]))
Python 解法, 执行用时: 10ms, 内存消耗: 2852KB, 提交时间: 2022-07-26
operators_dict = {'<': 'less than', '==': 'equal'} print('Here is the original dict:') for k,v in sorted(operators_dict.items()): print('Operator %s means %s.'%(k,v)) operators_dict['>'] = 'greater than' print('') print('The dict was changed to:') for k,v in sorted(operators_dict.items()): print('Operator %s means %s.'%(k,v))
Python 解法, 执行用时: 10ms, 内存消耗: 2856KB, 提交时间: 2022-06-15
operators_dict={'<': 'less than','==': 'equal'} print('Here is the original dict:') list1=list(operators_dict.keys()) list1=sorted(list1) for i in list1: print('Operator {} means {}.'.format(i,operators_dict[i])) operators_dict['>']='greater than' print('') print('The dict was changed to:') list2=list(operators_dict.keys()) list2=sorted(list2) for i in list2: print('Operator {} means {}.'.format(i,operators_dict[i]))
Python 解法, 执行用时: 10ms, 内存消耗: 2860KB, 提交时间: 2022-07-30
operators_dict={'<':'less than','==': 'equal'} print('Here is the original dict:') for i in sorted(operators_dict.keys()): print("Operator %s means %s."%(i,operators_dict[i])) operators_dict['>']='greater than' print('\nThe dict was changed to:') for k in sorted(operators_dict.keys()): print("Operator %s means %s."%(k,operators_dict[k]))