Python教程

python输出三角形

本文主要是介绍python输出三角形,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
# -*- coding: utf-8 -*-
# @Time : 2022/2/22 16:18
# @Author : Relieved


"""
line : 行数
Difference :差值
multiple : 倍率

"""


class OutStart:

    @staticmethod
    def RunAll(line=1, Difference=1, multiple=1):
        i = 1
        while i < line:
            j = 0
            while j < i:
                print("*", end="")
                j += 1
            print("")
            i = (i + Difference) * multiple


if __name__ == '__main__':
    try:
        vLine = int(input("vLine : 1 - 99"))
        vDifference = int(input("vDifference : 1 - 9"))
        vMultiple = int(input("vMultiple : 1 - 9"))
        if (1 <= vLine <= 99) or (1 <= vDifference <= 9) or (1 <= vMultiple <= 9):
            OutStart.RunAll(line=vLine, Difference=vDifference, multiple=vMultiple)
        else:
            print("Error : > Incorrect input <")
    except Exception as e:
        print(">>> ", e)

这篇关于python输出三角形的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!