Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

App Inventor

Authors: David Wolber, Hal Abelson

1st Edition

1449397484, 9781449397487

More Books

Students also viewed these Programming questions

Question

What are the economic benefits that options provide?

Answered: 1 week ago