#Copyright (c) 2017, University of northeastern Software College student
# all rightsreserved
#文件名称: a.py
#作 : Kongyun
#问题描述: Write a program that uses a double loop to output a triangular pattern.
#问题分析: This program by the graphics know, contains 5 lines, that is, the outer loop executes 5 times, each line of content consists of three parts: space, asterisk, carriage return, respectively, through two for loop and a print statement implementation. The code is as follows: for-I in range (
1,6):
with J in Range (5-i):
print ("", end= "") for
J in Range (1,2*i):
print ("*", End= "")
print ("\ n")
Run Result:
Note: The nesting of loop statements is not limited to the number of nesting layers, but the inner and outer layers of the loop cannot be crossed. In this program, note that for left alignment in the inner loop, there is also the last print statement output left-aligned, otherwise disrupting the loop order, can not implement the pattern in the running result.