w3resource

Python Exercise: Print alphabet pattern T


27. Alphabet Pattern 'T'

Write a Python program to print the alphabet pattern 'T'.

Pictorial Presentation:

Python Exercise: Print alphabet pattern T

Sample Solution:

Python Code:

result_str="";    
for row in range(0,7):    
    for column in range(0,7):     
        if (column == 3 or (row == 0 and column > 0 and column <6)):  
            result_str=result_str+"*"    
        else:      
            result_str=result_str+" "    
    result_str=result_str+"\n"    
print(result_str);

Sample Output:

 *****                                                                                                        
   *                                                                                                          
   *                                                                                                          
   *                                                                                                          
   *                                                                                                          
   *                                                                                                          
   *  

Flowchart :

Flowchart: Print alphabet pattern T

For more Practice: Solve these Related Problems:

  • Write a Python program to print the letter 'T' pattern with a full horizontal line at the top and a centered vertical line.
  • Write a Python program to generate 'T' using loops that print a row of stars followed by a column of spaces and a star in the center.
  • Write a Python program to construct the pattern for 'T' with proper centering by calculating the midpoint of the top row.
  • Write a Python program to implement the letter 'T' pattern using formatted strings to align the vertical stem.

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program to print the following pattern 'S'.
Next: Write a Python program to print alphabet pattern 'U'.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.