美文网首页
Python——while循环

Python——while循环

作者: 时吉助手 | 来源:发表于2019-11-02 13:35 被阅读0次

break

i = 0

while i < 10:

    if i == 3:
        break

    print(i)

    i += 1

print("over")

continue

i = 0

while i < 10:

    if i == 3:
        i += 1
        continue

    print(i)

    i += 1

print("over")

打印小星星

row = 1

while row <= 5:

    print("*" * row)

    row += 1

9*9乘法口诀表

row = 1

while row <= 9:

    col = 1

    while col <= row:

        print("%d * %d = %d" % (col, row, row * col), end = "\t")

        col += 1

    print("")
    
    row += 1

相关文章

网友评论

      本文标题:Python——while循环

      本文链接:https://www.haomeiwen.com/subject/rgmcbctx.html