正方向

height = int(input("please input height: "))

tmp = 1
while tmp <= height:
    width = tmp
    while width > 0:
        print("*", end="")
        width -= 1
    print("")
    tmp += 1

测试结果:

Python 练习:使用 * 输出直角三角形

 

反方向:

height = int(input("please input height: "))

while height > 0:
    tmp = height
    while tmp > 0:
        print("*",end="")
        tmp -= 1
    print()
    height -= 1

测试结果:

Python 练习:使用 * 输出直角三角形

相关文章:

  • 2021-06-17
  • 2022-02-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
  • 2021-11-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-26
  • 2022-12-23
  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
相关资源
相似解决方案