# 实验五

task3def main():    passif __name__ == '__main__':    main()with open('data3.txt','r')as f:    data=f.read().split('\n')del data[0]a=list(data)b,m=[],[]for i in data:    i=float(i)    m.append(i)    b.append(round(i))c=['原始数据\t四舍五入后数据\t\n']for i,j in zip(a,b):    c.append(str(i)+'\t'+str(j)+'\n')with open('data3_1.txt','w')as f:    f.write(''.join(c))print('原始数据')print(m)print('四舍五入后数据')print(b)

 1 with open('data4.txt','r',encoding='utf-8') as f:
3 b=[]
4 for i in a:
5     x=i.strip('\n').split('\t')
6     b.append(x)
7 c=b.pop(0)
8 for i in b:
9     b.sort(key=lambda i:(i[2],-int(i[-1])))
10 print('\t'.join(c))
11 for i in b:
12     print('\t'.join(i))
13 with open('data4_processed.txt','w') as f:
14     f.write('\t'.join(c))
15     for i in b:
16         f.write('\n')
17         f.write('\t'.join(i))

def main():    passif __name__ == '__main__':    main()with open('data5.txt','r',encoding='UTF-8') as f:    a=f.read()x=len(a.splitlines())y=len(a.split())z=a.count(' ')b=len(a)print('行数:',x)print('单词数:',y)print('空格数:',z)print('字符数:',b)m=1with open('data5_with_line.txt','w') as f:    for i in a.splitlines():        f.write(str(m))        f.write(' ')        f.write(i)        f.write('\n')        m=m+1