Python Program To Print Mirror Lower Star Triangle Pattern
Python Program To Print Mirror Lower Star Triangle Pattern
5
6
Example 2: -
lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
for i in lst:
print(i)
output: -
1
2
3
4
5
6
7
8
9
10
While loop: - A while loop is used to repeatedly run a block of
code until a specified condition is met.
Syntax :
while condition:
statement()
example 1: -
i=0
while (i < 3):
Harshit Sachan
i=i+1
print(“Hello, World!”)
output: -
Hello, World!
Hello, World!
Hello, World!
print(list(number))
output: -
[0, 1, 2, 3]
Problem statement: Given a number as input, the challenge
is to print a Mirror Lower Star Triangle Pattern with n rows,
where n is the inputted number.
The crucial thing to bear in mind is that we must print two
pyramids—one facing down and one facing upward—instead of
triangles, which means that in addition to printing stars, we
also need to consider the symmetry and the empty spaces in
both pyramids. This is what makes it substantially more
difficult because we did not have to think about the symmetry
in the case of right and left triangles.
Algorithm:
Start with Step 1
Declare the four integer values I j, k, and my input in step two.
Step 3: Read the user's needed values and define them.
Step 4: To get space between the characters, we run through
two nested "for" loops.
Step 5: After repeating the innermost loop, we repeat the 'for'
loop once more. This will assist in printing the necessary
character.
Step 6: Print a new line to determine how many characters will
appear in the next lines.
Step 7: Show the outcome
Stop at Step 8
Let us say that we are given 5 as input the pattern we will have to print is:
*****
****
Harshit Sachan
***
**
**
***
****
*****
Output:
Enter the number of rows: 8
********
*******
******
*****
****
***
**
*
*
**
***
****
*****
******
*******
********
output:
******
*****
****
***
**
Harshit Sachan
*
*
**
***
****
*****
******
Explanation: - The number of rows is input into the code above
as a static value. The outer loop is the next phase, and it
iterates from 6 to 1, decreasing with each iteration. The inner
loop outputs the number of stars equal to the value of the
outer loop's counter variable after each iteration. same, mirror
experiences the opposite