Answer to Question #207391 in Python for rakesh

Question #207391

Parallelogram

Write a program to print a parallelogram pattern with

* characters. The size N represents the length (the number of * characters in each line) & breadth (the number of lines) of the parallelogram.The slope of the parallelogram

T represents the number of extra spaces a line should have in the beginning compared to its next line. The last line of the pattern does not have any spaces in the beginning.Input

The input contains an integer

N.Output

The output should have

N lines. Each line should have spaces followed by N number of * characters as mentioned above.Explanation

Given

N = 3 and T = 2.Each line should have

3 star(*) characters. The last line should have 0 spaces at the beginning. Each line has 2 extra space characters when compared to its next line.

Sample Input 1

2 2

Sample Output 1

**

**

Sample Input 2

3 2

Sample Output 2

***

***

***


1
Expert's answer
2021-06-17T04:40:01-0400
#Python 3.9.5

def solidRhombus(rows, spaces_step):
    print ("\nSolid Rhombus:") 
    for i in range (1,rows + 1):
         
        # Print trailing spaces
         
        for j in range (1,rows - i + 1):
            print (end = spaces_step*" ")
             
        # Print stars after spaces
         
        for j in range (1,rows + 1):
            print ("*",end="")
             
        # Move to the next line/row
        print()
 
# driver program
 
if __name__ == "__main__":
    L = input().split()
    rows = int(L[0])
    spaces_step = int(L[1])
    solidRhombus(int(rows), int(spaces_step))

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