打印小星星
row = 1 while row <= 5: col = 1 while col <= row: #print("%d" % col) print("*", end="") col += 1 #print("第%d行" % row) print('') row += 1
打印九九乘法表
row = 1 while row <= 9: col = 1 while col <= row: print("%d * %d = %d" % (col, row, col*row), end=" ") col += 1 print() row += 1