(1) Define a function for summing data. The function name is addList (). List=[1,3,8,9,5,6] (3) Read data from List, and use addlist() function to sum. (4) Save the calculation result of summation in the file T1.txt.

Fp =open(‘ ceshi1.txt ‘,mode= ‘w’,encoding= ‘utf-8’) fp. Write (‘ ceshi1.txt ‘) fp. Close ()

Fp =open(‘ 888 ‘,mode= ‘r’,encoding= ‘utf-8’) read res=fp.read() print(res) close fp.close()

The data summation function

def addlist(n):

sum=0
for i in n:
    sum=sum+i
return sum

Jieguo = addlist,3,8,9,5,6 List = [1] (List) print (jieguo)

The file is written as follows

fp= open(‘t1.txt’,mode=’w+’)

fp.write(str(jieguo))

fp.close()