0% found this document useful (0 votes)
2 views1 page

11 Python CS

The document provides a Python code snippet to print a star pattern with 5 rows. It explains the program components, including variables, loops, and built-in functions used in the code. The outer loop controls the number of rows, while the inner loop prints the stars in each row.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

11 Python CS

The document provides a Python code snippet to print a star pattern with 5 rows. It explains the program components, including variables, loops, and built-in functions used in the code. The outer loop controls the number of rows, while the inner loop prints the stars in each row.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Q. Print the following pattern in Python.

*
**
***
****
*****
Code:
n=5
for i in range(1, n+1):
for j in range(1, i+1):
print("*", end=" ")
print()

Program Components Table:


Component Name/Code Type Description
Integer Holds the number of rows for
Variable n
Variable the pattern (5 in this case).
Iterates from 1 to n for each
Variable i Loop Variable
row.
Iterates from 1 to i to print
Variable j Loop Variable
stars in each row.
Built-in Generates a sequence of
Function range()
Function numbers used in the for loops.
Prints the output. In inner loop:
Built-in
Function print() prints *, in outer loop: prints
Function
newline.
Prevents the print() function
Print
Parameter end=" " from moving to a new line after
Parameter
each star.
for i in
Loop Outer Loop Controls the number of rows.
range(...)

You might also like