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

Create a Python function called printTriangle that expects one argument, a non-

ID: 3857917 • Letter: C

Question

Create a Python function called printTriangle that expects one argument, a non- negative integer, and prints a right triangle, where both the height of the triangle and the width of the widest part of the triangle are given by the value passed as the argument. This function does not return any value. Your function should use your solution to Problem 3 in printing the triangle. Here are some examples of how your function should behave:

>>> printTriangle(4)

####

###

##

#

>>> printTriangle(1)

#

>>> printTriangle(0)

>>>

Explanation / Answer

Problem 3 was not given, So I am providing the code to print the triangle.

function defination is

def printTriangle(height):
x = height
while x >= 1:
print ('#' * x)
x -= 1

This defination has a loop which runs from height to 1 and print # accordingly.

Sample run

>>> printTriangle(4)

>>> printTriangle(1)

>>> printTriangle(0)