Program to print the pattern T

In this program, we will print the pattern T.

Steps to solve the program

To Solve this we will divide the problem into 2 parts.

Part 1: Print horizontal lines.

* * * * * * * * *
* * * * * * * * *

1. Initiate a first loop with range(3)
2. Initiate a nested loop with range(9), through this it will
print a line of *
3. Once both loops are completed two horizontal lines will print.

Part 2: Print vertical lines.

     * * * 
     * * * 
     * * * 
     * * * 
     * * * 

4. Now print 2 vertical lines in the middle with another nested loop.
5. Initiate a second loop with range(5)
6. Initiate a nested loop with range(9), through this it will print
line of * in vertical line.

				
					# This for loop section will print 2 horizontal lines.
for i in range(2):
    for j in range(9):
        print("*", end="")
    print()

# This for loop section will print vertical line of T pattern.
for i in range(5):
    for j in range(9):
        if j> 2 and j <6:
            print("*", end="")
        else:
            print(" ", end="")
    print()
				
			

Output :

				
					*********
*********
   ***   
   ***   
   ***   
   ***   
   ***
				
			

print the multiplication table of any number

print number patterns

Leave a Comment