Python习题集:程序6
程序6
题目:用*号输出字母C的图案。
def print_c(hight=7): #打印字母C,默认高宽比为7:5 width = round(hight*5/7) for i in range(hight): match i: case 0: print(f" {'*'*(width-1)}") case j if 1 <= j <= hight-2: print("*") case j if j == hight - 1: print(f" {'*'*(width-1)}") if __name__ == "__main__": print_c()后记:
1.本例采用取巧的打印C方法,以后可以将字母变为字符画的方式编写。
2.继续熟练match语句。
