1.乘法口诀:
for i in range(1,10): for j in range(1,i+1): b = i * j print(f'{i}*{j}={b}',end=' ') print('')
2.水仙花数:
for i in range(100,999): bw = i//100 sw = (i%100)//10 gw = (i%100)%10 if bw**3+sw**3+gw**3 == i: print(i)
3.冒泡:
list= [44,55,9,5,6,77] for i in range(1,len(list)): for j in range(1,len(list)-i): if list[j]<list[j-1]: a = list[j] list[j] = list[j-1] list[j-1] = a print(list)
结果:
[44, 9, 55, 5, 6, 77] [44, 9, 5, 55, 6, 77] [44, 9, 5, 6, 55, 77] [9, 44, 5, 6, 55, 77] [9, 5, 44, 6, 55, 77] [9, 5, 6, 44, 55, 77] [5, 9, 6, 44, 55, 77] [5, 6, 9, 44, 55, 77]
每篇一句:
来不及 仔仔细细写下你的关于,描述我 多么爱你。