Answer to Question #289280 in Python for vinod

Question #289280

how to write code for hollow rigth angled triangle with different shapes of three side of a triangle

1
Expert's answer
2022-01-21T01:46:30-0500

triangle is said to be right-angled if it has an angle equal to 90 degrees on its left side.

We will use 2 for loops:

  • Outer loop: To handle the number of rows.
  • Inner loop: To handle the number of columns.
  # Number of rows
n = 5
# Loop through rows
for i in range(1, n+1):
    # Loop through columns
    for j in range(1, n+1):
        # Printing Pattern
        if (i == j) or (j == 1) or (i == n):
            print("*", end=" ")
        else:
            print(" ", end=" ")
    print()  


Output:

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









Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS