Question: Fix A Program. There Are Four Errors In The Following Code, You Need To Find Them And Fix The Code. Hints: You May Add Something

Fix A Program. There Are Four Errors In The Following Code, You Need To Find Them And Fix The Code. Hints: You May Add Something To The Code Or Modify Some Values, But Do Not Remove Anything From The Code. Def Draw_triangle(): For I In Range(H): Print(" " * (H - I - 1) + "*" * (I*2 + 1)) Done = True While Not Done: # DO NOT MODIFY THIS LINE!!!

Fix a program.There are four errors in the following code, you need to find them and fix the code.Hints:You may add something to the code or modify some values, but do not remove anything from the code.

def draw_triangle(): for i in range(h): print(" " * (h - i - 1) + "*" * (i*2 + 1))done = Truewhile not done: # DO NOT MODIFY THIS LINE!!! height = input("Please enter the height of a triangle: ") draw_triangle(height) ans = input("Do you want to quit? [Y/N]: ").upper() if ans == "Y": done = False

Here is the output of the fixed program if the user enters 4, n, 6, and y:

Please enter the height of a triangle: 4 * *** ************Do you want to quit? [Y/N]: nPlease enter the height of a triangle: 6 * *** ***** ******* ********************Do you want to quit? [Y/N]: y

You can write your fixed code below, please use thepreformatted textinstead ofparagraph(you can choose it from the menu bar above the following text box).

View keyboard shortcuts

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!