for i in range(1,①): for j in range(1,len(a)-i): if int(a[j][1])<int(a[j+1][1]) and a[j][2]==a[j+1][2]: a[j],a[j+1]=a[j+1],a[j] elif a[j+1][2]==“女“or a[j][2]==“男“: a[j],a[j+1]=a[j+1],a[j] a[1][3]=1 for i in range(2,len(a)): if a[i][1]!=a[i-1][1]: a[i][3]=i else: ② t=0 for i in range(1,len(a)): if a[i][2]==“女“: ③ else: a[i][3]=a[i][3]-t #輸出數(shù)據(jù)a到文件中,代碼略
分 (2)實(shí)現(xiàn)上述功能的程序如下,請(qǐng)?jiān)跈M線處填入合適的代碼。 from PIL import Image #輸入起始點(diǎn)坐標(biāo)(xs,ys),信息點(diǎn)寬度高度(fw,fh),間隔寬度高度(sw,sh),代碼略 num=5#判分個(gè)數(shù) def bw_judge(R,G,B):#bw_judge用于判斷一個(gè)像素的填涂情況 代碼略 def fill_judge(x,y):#fill_judge用于判斷信息點(diǎn)的填涂情況 count=0 for i in range(x,x+fw+1): for j in range(y,y+fh+1): R,G,B=pixels[i,j] if bw_judge(R,G,B)==True: count=count+1 if count>=①: return True
total_width=fw+sw total_height=fh+sh image=Image.jye.ai(“t2.bmp“) pixels=image.jye.ai( ) number=““ bz=[““]*num df=0 bzd=input('請(qǐng)輸入標(biāo)準(zhǔn)答案:') da={“A“:“1000“,“B“:“0100“,“C“:“0010“,“D“:“0001“} for i in range(len(bzd)): bz[i]=② for row in range(num):#分?jǐn)?shù)判定 for col in range(4): ③ y=ys+total_height*row if fill_judge(x,y)==True: number=number+'1' else: number=number+'0' if number==bz[row]: df+=2 number=““ print(“得分為:“,df)