今天第三章收尾了!先是把第三章最后一点内容列表的排序看完了,做了一个系统的串联所有排序函数的练习题,之后把第三章整体快速过了一遍,尤其是几个不太熟悉的函数又把他们和上述例子放在一起用算法实现了一遍,具体代码实现见下方。
cars=['a','e','b','d','c']
print('original')
print(cars)
print('after sorted ')
print(sorted(cars))
print(cars)
print('sorted reverse')
print(sorted(cars,reverse=True))
print(cars)
print("after reverse")
cars.reverse()
print(cars)
print('reverse and reverse')
cars.reverse()
print(cars)
print('after sort')
cars.sort()
print(cars)
print('after sort reverse')
cars.sort(reverse=True)
print(cars)
print(len(cars))
del cars[0]
print(cars)
cars.insert(0,'ee')
print(cars)
popped_cars=cars.pop(-1)
print(popped_cars)
print(cars)
cars.remove('b')
print(cars)