Answer to Question #178431 in Python for jayanth

Question #178431

Right Angle Triangle

Given an integer N, write a program to print a right angle triangle pattern similar to the pattern shown below

    /|
   / |
  /  |
 /   |
/____|

Input


The input will be a single line containing a positive integer (N).Output


The output should be N lines containing the triangle pattern.Explanation


For example, if the given number is 5, the pattern should be printed in 5 lines, as shown below

    /|
   / |
  /  |
 /   |
/____|

Sample Input 1

5

Sample Output 1

/|

/ |

/ |

/ |

/____|

Sample Input 2

4

Sample Output 2

/|

/ |

/ |

/___|




1
Expert's answer
2021-04-05T10:33:42-0400
n = int(input())
for i in range(n):
	print(' ' * (n - i) + '/', end = '')
	if i < n-1:
		print(' ' * i, end = '')
	else:
		print('_' * i, end = '')
	print('|')

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