Fix A Program. There Are Four Errors In The Following Code, You Need To Find Them And
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 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 = FalseHere 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]: yYou 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