Answer to Question #287218 in Python for CCBP

Question #287218

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

Explanation

For example, if the given number is

5, the output should be

______

| /

| /

| /

| /

| /


for example:

The input is 5. In the first row, we need to print N+1 underscores i.e.,6. After the row with underscores, we need to print the 5 rows. For every row from 2nd row to Nth row i.e; 5 starts with | and ends with /.



can you provide python code for this ?


thanks in advance


1
Expert's answer
2022-01-13T07:46:48-0500
N = int(input())
for i in range(N+1):
    print('_', end='')
print()
for i in range(N):
    print('|', end='')
    print(' ' * (N - i - 1), 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