Answer to Question #266197 in Python for Bayernmunich

Question #266197

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


Note: There is a space after each asterisk ( * ) character


In the given example the solid right angled triangle of side 4. Therefore, the output should be.


* * * *

  * * *

   * *

     *


1
Expert's answer
2021-11-15T00:22:40-0500
num = int(input("Enter a positive integer: "))

for i in range(1,num + 1):
    for j in range(1,num + 1):
        if j < i:
            print(' ', end = ' ')
        else:
            print('*', end = ' ')
    print()


Enter a positive integer: 4
* * * * 
  * * * 
    * * 
      * 

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