day04 作業答案
阿新 • • 發佈:2018-11-04
1.
1)
li=['alex','WuSir','ritian','barry','wenzhou'] print(len(li))
2)
li=['alex','WuSir','ritian','barry','wenzhou'] li.append('seven') print(li)
3)
li=['alex','WuSir','ritian','barry','wenzhou'] li.insert(1,'Tony') print(li)
4)
li=['alex','WuSir','ritian','barry','wenzhou'] li[2]='Kelly' print(li)
5)
li=['alex','WuSir','ritian','barry','wenzhou'] li2=[1,'a',3,4,'heart'] li.extend(li2) print(li)
6)
li=['alex','WuSir','ritian','barry','wenzhou'] li2='qwert' li.extend(li2) print(li)
7)
li=['alex','WuSir','ritian','barry','wenzhou'] li.remove('alex') print(li)
8)
li=['alex','WuSir','ritian','barry','wenzhou'] a=li.pop(2) print(li) print(a)
9)
li=['alex','WuSir','ritian','barry','wenzhou'] del li[2:4] print(li)
10)
li=['alex','WuSir','ritian','barry','wenzhou'] a=[] li2=li[::-1] a.extend(li2) print(a)
11)
li=['alex','WuSir','ritian','barry','wenzhou'] a=li.count('alex') print(a)
2.
1)
li=[1,3,2,'a',4,'b',5,'c'] l1=li[0:3] print(l1)
2)
li=[1,3,2,'a',4,'b',5,'c'] l1=li[3:6] print(l1)
3)
li=[1,3,2,'a',4,'b',5,'c'] l1=li[0::2] print(l1)
4)
li=[1,3,2,'a',4,'b',5,'c'] l1=li[1:-2:2] print(l1)
5)
li=[1,3,2,'a',4,'b',5,'c'] l1=li[-1] print(l1)
6)
li=[1,3,2,'a',4,'b',5,'c'] l1=li[-3:0:-2] print(l1)
3.
1)
li=[2,3,'k',['qwe',20,['k1',['tt',3,'1']],89],'ab','adv'] li[3][2][1][0]='TT' lis[3][2][1][0] = lis[3][2][1][0].replace("t", "T") print(li)