i = 0 while i < 5: print('*' * 5,end='n') i += 1python 里可以用一个循环打印三角形
i =0 while i < 5: i += 1 print(i * '*')嵌套循环打印矩形
#嵌套打印矩形 #总结外循环控制行数,内循环控制列数 # print('*',end=' ') # print('*',end=' ') # print('*',end=' ') # print('*',end=' ') # print('*',end='') # print() k = 0 while k < 5: k += 1 j =0 while j < 5: j += 1 print('*',end=' ') print()嵌套循环打印三角形
k = 0 while k < 5: k += 1 j =0 while j < k: j += 1 print('*',end=' ') print()打印九九乘法表
j = 0 while j < 9: j +=1 i = 0 while i < j: i += 1 print(i,'*',j,'=',(i*j),sep='',end='t') print()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)