摘要:
'''求两个数的最大公约数'''def gys(x,y): # 判断两个数字大小 if x>y: smaller = y bigger = x else: smaller=x bigger=y # case1:两个数可以整除 if bigger%smaller==0: return smaller 阅读全文
摘要:
'''10-50中个位数带有5的所有数字'''def dig(): a=[] for i in range(10,51): if str(i)[-1]=="5": a.append(i) return aprint(dig())print("符合条件的个数为:"+str(len(dig()))) 阅读全文
摘要:
'''打印一个数的阶乘''' def fac(n): if n==0 or n==1: return 1 result=1 for i in range(1,n+1): result*=i return resultprint(fac(5)) 阅读全文
摘要:
'''交通信号灯显示颜色:红灯后是绿灯,绿灯后是黄灯,黄灯后是红灯'''def update_light(current): current_list = ["red","green","yellow"] n = current_list.index(current) if n ==(len(cur 阅读全文
摘要:
'''打印1234组成的不重复三位数'''count=0data=[]for i in range(1,5): for j in range(1,5): for k in range(1,5): if i!=j and i!=k and j!=k: count+=1 a=str(i)+str(j)+ 阅读全文