On the use of dictionaries by python

such as the picture, the content of the final training examination, I have been working on it for three days, and it will be handed in the day after tomorrow. I would like to ask for help. I would appreciate it again and attach the code I wrote

. < hr > < H1 > Task one < / H1 >

def one (path):

for i in open(path):
    list1=i.split()
    tuple1=tuple(list1)
    print(tuple1)
< H1 > Task two < / H1 >

def tow (path):

open_tmp=open(path)
key_tmp=open_tmp.readline()
key1=key_tmp.split()
for i2 in open_tmp:
    key2=i2.split()
    zip_put=dict(zip(key1,key2))  
    print(zip_put)
    

< hr >

Mar.26,2021

< H1 > 1 < / H1 >

for i in open ('score.txt', 'r'):

list1=i.split()
tuple1=tuple(list1)
print(tuple1)
< H1 > 2 < / H1 >

open_tmp=open ('score.txt', 'r')
key_tmp=open_tmp.readline ()
key1=key_tmp.split ()
stu_info = []
for i2 in open_tmp:

key2=i2.split()
zip_put=dict(zip(key1,key2))
stu_info.append(zip_put)
< H1 > 3 < / H1 >

def three ():

score = []
m_score = []
f_score = []
for dct in stu_info:
    sco = dct['score']
    score.append(sco)
    if dct['sex'] == 'm':
        sc_m = dct['score']
        m_score.append(sc_m)
    if dct['sex'] == 'f':
        sc_f = dct['score']
        f_score.append(sc_f)

-sharp 
for stu in stu_info:
    if stu['score'] == max(score):
        print(stu)
-sharp 
for stu in stu_info:
    if stu['score'] == min(score):
        print(stu)

def avg(score):
    sum = 0
    for i in score:
        sum += int(i)
    avg = sum/len(score)
    return avg
-sharp 
print(avg(score))
print(avg(m_score))
print(avg(f_score))

three ()

< H1 > 4 < / H1 >

def four ():

-sharp 
with open("score.txt","r",encoding="utf-8") as f:
    lines = f.readlines()
with open("score.txt","w",encoding="utf-8") as f_w:
    for line in lines:
        if "" in line:
            line = line.replace("", '')
        f_w.write(line)
-sharp 
with open("score.txt","r",encoding="utf-8") as f:
    lines = f.readlines()
with open("score.txt","w",encoding="utf-8") as f_w:
    f_w.write('')

-sharp 
with open("score.txt","r",encoding="utf-8") as f:
    lines = f.readlines()
with open("score.txt","w",encoding="utf-8") as f_w:
    for line in lines:
        if "" in line:
            continue
        f_w.write(line)

four ()

Menu