3、名同学的平均分为:{:.2f}".format(ave))print("5名同学的最高分为:{:.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)七计算圆的面积importmatha=math.pir=eval(input("请输入圆的半径r=:"))s=a*r*rprint("{:.2f}".format(s))八顺序查找(要查找的数不存在返回-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("请输入要查找的数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("请输入要查找的数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)十一、密码验证key=input("请输入密码:")ifkey.lower()=="python123":print("正确")else:print("错误")十二、十进制转换二进制num=eval(input("请输入一个十
8、进制数:"))s=[]ifnum==0:print(num)whilenum>0:r=num%2s.append(r)num=num//2whilelen(s)>0