Python练习题:2 输出指定整数及星号图形

写代码完成以下图形

Python练习题:2 输出指定整数及星号图形_第1张图片

自己写:

temp = input("请输入一个整数:")
intnum = int(temp)
add = 0
while intnum != add:
    add = add + 1
    print(add)

甲鱼老师:

temp = input("请输入一个整数:")
intnum = int(temp)
add = 0
while intnum != add:
    add = add + 1
    print(add)

 

Python练习题:2 输出指定整数及星号图形_第2张图片

temp = input("请输入一个整数:")
record = int(temp)

while record:
    kong = record - 1
    while kong > 0:
        kong = kong - 1
        print(" ",end = '')
    star = record
    while star > 0:
        star = star - 1
        print("*",end = '')
    print()
    record = record - 1

 

你可能感兴趣的:(Python)