li = ['Rose','Antony','Geroge']
for i in li:
print(i+'_',end='')
li = ["alec", " aric", "Alex", "Tony", "rain"]
tu = ("alec", " aric", "Alex", "Tony", "rain")
dic = {'k1': "alex", 'k2': ' aric', "k3": "Alex", "k4": "Tony"}
list1 = list(tu)
list2 = list(dic.values())
list3 = list1+list2+li
for i in list3:
kg = i.strip()
if (kg.startswith('a') or kg.startswith('A') or kg.endswith('c')):
print(kg)
li = ['Rose','Antony','Geroge']
print(len(li))
li.append("seven")
print(li)
li.insert(0,'Tony')
li.insert(1,'Kelly')
print(li)
del_li = li.pop(1)
print(del_li)
print(li)
del li[2]
print(li)
del li[2:4]
print(li)
li.reverse()
print(li)
for i in range(len(li)):
print(i,end=' ')
print()
print(list(enumerate(li, start=100)))
for i in li:
print(i,end=' ')
li = ["hello", 'seven', ["mon", ["h", "kelly"], 'all'], 123, 446]
print(li[2][1][1])
li[2][2]='ALL'
print(li)
tu = ("alex", [11, 22, {"k1": 'v1', "k2": ["age", "name"], "k3": (11,22,33)}, 44])
tu[1][2]['k2'].append('seven')
print(tu)
print('不可以,因为k3是一个元组')
s = "alex"
ss = list(s)
print(ss)
i = tuple(s)
print(i)
li = ["alex", "seven"]
tu = tuple(li)
print(tu)
tu = ('Alex', "seven")
tuu = list(tu)
print(tuu)
li = ["alex", "seven"]
dict= {}
j = 10
for i in li:
dict[j] = i
j+=1
print(dict)
s = {11,22,33,44,55,66,77,88,99,90}
dict = {'key1':[],'key2':[]}
for i in s:
if i >66:
dict['key1'].append(i)
elif i <66:
dict['key2'].append(i)
print(dict)
li = [1,3,2,7,6,23,41,243,33,85,56]
print(max(li))
li = [-100,1,3,2,7,6,120,121,140,23,411,99,243,33,85,56]
print((max(li)+min(li))/2)
for i in range(1,10):
for j in range(1,i+1):
print('{}X{}={}'.format(j,i,i*j),end='\t')
print()
sum=0
for i in range(2,100):
for j in range(2,i):
if (i%j==0):
break
else:
sum+=i
print(sum)
fp = open("De.py",encoding = 'utf-8')
code = len(open("De.py",encoding = 'utf-8').readlines())
null = 0
notes = 0
for i in fp.readlines():
i = i.strip()
if i == "":
null += 1
if i.startswith("#"):
notes += 1
print("\n该文件共有%d行代码" %code)
print("其中%s行空行" %null)
print("其中%s行注释" %notes)
|