学习笔记(23):21天通关Python(视频课)-案例实操-控制台打印菱形和圆(上)

立即学习:https://edu.csdn.net/course/play/24797/282175?utm_source=blogtoedu

a = int(input("请输入希望打印菱形层数:"))
for i in range(a):
    if i == 0:
        print(" "*a+"*")
    else:
        print(" "*(a-i)+"*"+" "*(i*2-1)+"*")
for j in range(a-1):
    if j == a-2:
        print(" "*a+"*")
    else:
        print(" "*(j+2)+"*"+" "*((a-j-2)*2-1)+"*")

 

你可能感兴趣的:(研发管理)