Answer to Question #219452 in Python for chandu

Question #219452

Given an integer number N as input. Write a program to print the right-angled triangular pattern of N rows as shown below.

Input

The first line of input is a positive integer.

Explanation

For example, if the given number is

5, the output should be

______
|    /
|   /
|  /
| /
|/

7,the out put should be

________
|      /
|     /
|    /
|   /
|  /
| /
|/




1
Expert's answer
2021-07-24T07:07:27-0400
n = int(input('Please enter a positive integer: '))
for i in range(n):
    print("_", end='')


print()
for i in range(n+1):
    for j in range(n-i):
        if(j == 0):
            print("|",end='')
        if(j == n-i-1):
            print("/", end='')
        else:
            print(" ", 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