Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a Python function that prints a parallelogram with asterisks. This functi

ID: 3667543 • Letter: C

Question

Create a Python function that prints a parallelogram with asterisks. This function will be called printPar and will have two parameters. The first parameter represents the width of the parallelogram, and the second parameter represents the height of the parallelogram. The first row of asterisks is printed (height - 1) spaces from the left edge of the display. The next row is printed (height - 2) spaces from the left edge, and so on. A parallelogram with width = 3 and height = 5 would be printed like this: You may assume that the arguments passed to your function are always non-negative integers. To simplify your function, you may want to write another function whose purpose is to print a row of characters. Here are some examples of how your function should behave:

Explanation / Answer

def printPar(w,h):

   row = ""
   for i in range(0,h):
       row = " "*(h-i-1) + "*"*w
       print row

printPar(3,5)
printPar(5,3)