4-1. 编写程序,输出下面(a)、(b)和(c)图案@。 程序压缩后(zip)以文件形式上传!
def printOne(high):
for z in range(1, high + 1):
for z1 in range(1, z + 1):
print('*', end='')
print()
def printTwo(high):
for z in range(1, high + 1):
for z1 in range(high, z, -1):
print(' ', end='')
for z1 in range(1, 2 * z):
print('*', end='')
print()
def printThree(high):
printTwo((high+1)//2)
for z in range(0,high//2):
for z1 in range(0,z+high%2):
print(' ', end='')
for z1 in range(1,2*(high//2-z)):
print('*', end='')
print()
print("请分别输入你要打印的图形类型: 1-直角三角形,2-等腰三角形,3-菱形")
command = int(input())
print("请输入你要打印行数 n")
n = int(input())
if command == 1:
printOne(n)
elif command == 2:
printTwo(n)
elif command == 3:
printThree(n)
else:
print("你输入有误")
print('程序已退出')