標題:
串列 (二)
[打印本頁]
作者:
tonyh
時間:
2019-7-16 11:33
標題:
串列 (二)
假設有一串列其內容如下:
list=[12,-3,-50,32,25,11]
試以sort()、reverse()、len()、pop()、append()、insert()等函式,完成如下操作:
list=[12,-3,-50,32,25,11]
print("排序前:",list)
list.sort();
print("排序後(遞增):",list)
list.reverse();
print("排序後(遞減):",list)
print("元素數量:",len(list))
list.pop()
print("pop掉一元素",list)
list.append(-20)
print("append一元素",list)
list.insert(4,0)
print("insert一元素",list)
複製代碼
作者:
張彥承
時間:
2019-7-16 11:55
list=[12,-3,-50,32,25,11]
print("排序前:",list)
list.sort()
print("排序後(遞增):",list)
list.reverse()
print("排序後(遞減):",list)
print("元素數量:",len(list))
list.pop()
print("pop掉一個元素",list)
list.append(-20)
print("append一個元素:",list)
list.insert(4,0)
print("insert一個元素:",list)
複製代碼
作者:
穆玨諺
時間:
2019-7-16 11:55
list=[12,-3,-50,32,25,11]
print("排序前:",list)
list.sort();
print("排序後(遞增):",list)
list.reverse();
print("排序後(遞減):",list)
print("元素數量:",len(list))
list.pop()
print("pop掉一元素",list)
list.append(-20)
print("append一元素",list)
list.insert(4,0)
print("insert一元素",list
複製代碼
作者:
黃宇綸
時間:
2019-7-16 11:55
list=[12,-3,-50,32,25,11]
print("排序前:",list)
list.sort()
print("排序後(遞增):",list)
list.reverse()
print("排序後(遞減):",list)
print("元素數量:",len(list))
list.pop()
print("pop掉一元素:",list)
list.append(-20)
print("append一元素:",list)
list.insert(4,0)
print("insert一元素:",list)
複製代碼
作者:
穆宥臻
時間:
2019-7-16 11:55
list=[12,-3,-50,32,25,11]
print("排序前:",list)
list.sort();
print("排序後(遞增):",list)
list.reverse();
print("排序後(遞減):",list)
print("元素數量:",len(list))
list.pop()
print("pop掉一元素",list)
list.append(-20)
print("append一元素",list)
list.insert(4,0)
print("insert一元素",list)
複製代碼
作者:
李宇澤
時間:
2019-7-16 11:58
list=[12,-3,-50,32,25,11]
print("排序前:",list)
list.sort();
print("排序後(遞增):",list)
list.reverse();
print("排序後(遞減):",list)
print("元素數量:",list)
list.pop()
print("pop掉一元素",list)
list.append(-20);
print("append一元素",list)
list.insert(4,0);
print("insert一元素",list)
複製代碼
作者:
黃宇瑄
時間:
2019-7-16 11:59
list=[12,-3,-50,32,25,11]
print("排序前: ",list)
list.sort()
print("排序後(遞增): ",list)
list.reverse()
print("排序後(遞減): ",list)
print("元素數量: ",list)
list.pop()
print("pop掉一元素 ",list)
list.append(-20)
print("append一元素 ",list)
list.insert(4,0)
print("insert一元素 ",list)
複製代碼
作者:
蔡沛倫
時間:
2019-7-16 12:01
list=[12,-3,-50,32,25,11]
print("排序前: ",list)
list.sort( );
print("排序後(遞增): ",list)
list.reverse();
print("排序後(遞減):" ,list)
print("元素數量: ",len(list))
list.pop()
print("pop掉一元素",list)
list.append(-20)
print("append一元素",list)
list.insert(4,0)
print("insert一元素",list)
複製代碼
作者:
王禹恆
時間:
2019-7-16 12:01
list=[12,-3,-50,32,25,11]
print("排序前:",list)
list.sport();
print("排序後(遞增):",list)
list.reverse();
print("排序後(遞增):",list)
print("元素數量:",len(list))
list.pop()
print("pop掉一個元素:",list)
list.append(-20)
print("append一元素:",list)
list.insert(4,0)
print("insert一元素:",list)
複製代碼
作者:
孫紹普
時間:
2019-7-16 12:02
list=[12,-3,-50,32,25,11]
print("排序前:",list)
list.sort()
print("排序後(遞增):",list)
list.reverse()
print("排序後(遞減):",list)
print("元素數量",len(list))
list.pop()
print("pop掉一元素",list)
list.append(-20)
print("append一元素",list)
list.insert(4,0)
print("insert一元素",list)
list.remove(25)
print(list)
複製代碼
作者:
林凱楓
時間:
2019-7-16 12:03
list=[12,-3,-50,32,25,11]
print("排序前:",list)
list.sort()";
print("排序後(遞增):",list)
list.reverse();
print("排序後(遞減):",list)
print("元素數量:",len(list))
list.pop()
print("pop掉一元素",list)
list.append(-20)
print("append一元素",list)
list.insert.(4,0)
print("insert一元素,list)
複製代碼
作者:
黃鋐粟
時間:
2019-7-16 12:04
list=[12,-3,-50,32,25,11]
print("排序前:",list)
list.sort();
print("排序後(遞增)",list)
list.reverse();
print("排序後(遞減)",list)
print("元素數量",len(list))
list.pop()
print("pop掉一個元素")
list.append(-20)
print("append掉一個元素")
list.insert(4,0)
print("insert掉一個元素")
作者:
王柏諺
時間:
2019-7-16 12:05
list=[12,-3,-50,32,25,11]
print("排序前:",list)
list.sort();
print("排序後(遞增):",list)
list.reverse();
print("排序後(遞減):",list)
print("元素數量:",len(list))
list.pop()
print("pop掉一元素",list)
list.append(-20)
print("append一元素",list)
list.insert(4,0)
print("insert一元素",list)
複製代碼
作者:
王宥媗
時間:
2019-7-16 12:05
list=[12,-3,-50,32,25,11]
print("排序前: ",list)
list.sort( );
print("排序後(遞增): ",list)
list.reverse();
print("排序後(遞減):" ,list)
print("元素數量: ",len(list))
list.pop()
print("pop掉一元素",list)
list.append(-20)
print("append一元素",list)
list.insert(4,0)
print("insert一元素",list)
複製代碼
作者:
曾博宇
時間:
2019-7-16 12:05
list=[12,-3,-50,32,25,11]
print("排序前:",list)
list.sort();
print("排序後(遞增):",list)
list.reverse();
print("排序後(遞減):",list)
print("元素數量",len(list))
list.pop();
print("pop掉一個元素:",list)
list.append(-20);
print("append一元素:",list)
list.insert(4,0);
print("insert一元素:",list)
複製代碼
作者:
楊子毅
時間:
2019-7-16 12:06
list=[12,-3,-50,32,25,11]
print("排序前:",list)
list.sort();
print("排序後(遞增):",list)
list.reverse();
print("排序後(遞減):",list)
print("元素數量:",len(list))
list.pop()
print("pop掉一元素",list)
list.append(-20)
print("append一元素",list)
list.insert(4,0)
print("insert-元素",list)
複製代碼
作者:
王銘鴻
時間:
2019-7-16 12:32
list=[12,-3,-50,32,25,11]
print("排序前:",list)
list.sort();
print("排序後(遞增):",list)
list.reverse();
print("排序後(遞減):",list)
print("元素數量:",len(list))
list.pop()
print("pop掉一元素:",list)
list.append(-20)
print("排序後(遞增):",list)
list.insert(4,0)
print("排序後(遞增):",list)
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2