本文最后更新于 784 天前,其中的信息可能已经有所发展或是发生改变。
下载习题
| names = ['wjq', 'lys', 'hfcj', 'xhz', 'jcg'] |
| for i in names: |
| print(i) |
| names = ['wjq', 'lys', 'hfcj', 'xhz', 'jcg'] |
| for i in names: |
| print(f"hello,{i}!") |
| names = ['wjq', 'hfcj', 'xhz', 'jcg'] |
| for i in names: |
| print(f"Hello,{i}! Would you like to have a dinner for me?") |
| names = ['wjq', 'hfcj', 'xhz', 'jcg'] |
| for i in names: |
| print(f"Hello,{i}! Would you like to have a dinner for me?") |
| print(f"Unfortunately, {names[1]} couldn't come.") |
| names[1] = 'mcc' |
| for i in names: |
| print(f"Hello,{i}! Would you like to have a dinner for me?") |
| names = ['wjq', 'hfcj', 'xhz', 'jcg'] |
| print("I have found a bigger table for the party") |
| names.insert(0, 'lrh') |
| names.insert(len(names)//2, 'mcc') |
| names.append('lsh') |
| for i in names: |
| print(f"Hello,{i}! Would you like to have a dinner for me?") |
| names = ['wjq', 'hfcj', 'xhz', 'jcg'] |
| print("I have found a bigger table for the party") |
| names.insert(0, 'lrh') |
| names.insert(len(names)//2, 'mcc') |
| names.append('lsh') |
| for i in names: |
| print(f"Hello,{i}! Would you like to have a dinner for me?") |
| print(f"Unfortunately, I could only invite tow guys to the party!") |
| while(len(names) > 2): |
| names.pop() |
| for i in names: |
| print(f"Wow! {i} is still in the list !") |
| del names[:] |
| print(names) |
| locations = ['Singapore', 'Hong Kong', 'Australia', 'Russia', 'Spain', 'France'] |
| for i in locations: |
| print(i) |
| print(sorted(locations)) |
| print(sorted(locations, reverse=True)) |
| print(locations) |
| locations.reverse() |
| print(locations) |
| locations.reverse() |
| print(locations) |
| locations.sort() |
| print(locations) |
| locations.sort(reverse=True) |
| print(locations) |