python的while嵌套 99乘法表 三角形和正方形

python的99乘法表

num1=1
while num1<=9 :
    num2 = 1
    while num2 <=num1 :
        print (str(num2)+"X"+str(num1)+"="+str(num2*num1),end="\t")
        num2+=1
    num1+=1
    print()
99乘法表

python自定义长高的矩形

width=int(input("width:"))
height=int(input("height:"))
while width>0 :
    gao=height
    while gao>0 :
        print("#",end="")
        gao-=1
    width-=1
    print()
用户自定义长高的矩形

python的三角形

num1=5
while num1>=0 :
    num2=5
    while num2>num1 :
        print("#",end="")
        num2-=1
    num1-=1
    print()
python的三角形

通过3个代码 简单了解python中while嵌套的使用  。

之前学PHP的时候也有使用while嵌套写99乘法口诀,但是都忘了,很难记住。

while嵌套对于新手来说还是有一点绕的,要多熟悉多练习,多吃核桃,健脑学习。

posted on 2017-09-02 20:19  王羿贺  阅读(812)  评论(0)    收藏  举报