单选题
适中
#18201
执行下面Python代码后,输出的结果是?( ) tuples = [ ( 1 , 'apple' ) , ( 2 , 'banana' ) , ( 0 , '…
执行下面Python代码后,输出的结果是?( )
答案与解析
正确答案:D
解析
sorted()函数根据元组的第二个元素进行排序。对于’apple’, ‘banana’, 和’cherry’,它们的排序顺序是’apple’, ‘banana’, ‘cherry’,所以输出结果是[(1, ‘apple’), (2, ‘banana’), (0, ‘cherry’)]