3、名同學(xué)的平均分為:{:.2f}".format(ave))print("5名同學(xué)的最高分為:{:.2f}".format(Max))四九九乘法表foriinrange(1,10):forjinrange(1,i+1):print("{}*{}={:<2}".format(j,i,i*j),end='')print('')五冒泡程序A=[12,36,54,65,55,65,48,98,76,11,54]n=len(A)foriinrange(1,n):forjinrange(0,n-i):ifA[j]>A[j+1]:A[j],A[j+1]=A[
4、j+1],A[j]print(A)六插入排序A=[12,36,54,65,55,65,48,98,76,11,54]n=len(A)____________________________________________________________________________________________________ifn==1:print(A)else:forxinrange(1,n):i=n-1whilei>0:ifA[i-1]>A[i]:A[i-1],A[i]=A[i],A[i-1]i=i-1else:i=i-1print
5、(A)七計(jì)算圓的面積importmatha=math.pir=eval(input("請(qǐng)輸入圓的半徑r=:"))s=a*r*rprint("{:.2f}".format(s))八順序查找(要查找的數(shù)不存在返回-1)deflinearSearch(A,x):foriinrange(0,len(A)):ifA[i]==x:returni____________________________________________________________________________________________________return-
6、1A=[1,3,5,6,8,9,11,13,14,15,19,22]x=eval(input("請(qǐng)輸入要查找的數(shù)x:"))n=linearSearch(A,x)print("x在A中索引值為:",n)九二分查找A=[1,3,5,6,8,9,11,13,14,15,19,22]x=eval(input("請(qǐng)輸入要查找的數(shù)x:"))a=0c=len(A)-1whilea<=c:b=(a+c)//2ifA[b]==x:print("x在A中的索引值為:",b)breakelifA[b]7、aglfgalfgdjldfaffuakdha"b={}foriina:____________________________________________________________________________________________________b[i]=b.get(i,0)+1print(b)十一、密碼驗(yàn)證key=input("請(qǐng)輸入密碼:")ifkey.lower()=="python123":print("正確")else:print("錯(cuò)誤")十二、十進(jìn)制轉(zhuǎn)換二進(jìn)制num=eval(input("請(qǐng)輸入一個(gè)十
8、進(jìn)制數(shù):"))s=[]ifnum==0:print(num)whilenum>0:r=num%2s.append(r)num=num//2whilelen(s)>0