笔记之九九乘法表

打印阶梯星星
# *
# **
# ***
# ****
# *****
# ******
# *******
# ********
# *********


# row = 1
#
# while row <= 9:
#     col = 1
#     while col <= row:
#         print('*', end="")
#         col += 1
#     print('')
#     row += 1
View Code

打印九九乘法表( 采用while循环嵌套, row 在外层循环, col在内存循环,col每次循环的能取的最大值是当前row)

row = 1

while row <= 9:
    col = 1
    while col <= row:
        print('{} * {} = {}'.format(col, row, col * row), end="\t")
        col += 1

    print('')
    row += 1

 

\t 是制表符

 

posted @ 2020-09-13 17:19  candidjuan  阅读(138)  评论(0)    收藏  举报