Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hi there I've used the except statement, expecting to avoid the error. but it doesn't work Need some help thx 1801020 Labos Debugging page 4
Hi there
I've used the except statement, expecting to avoid the error. but it doesn't work
Need some help
thx
1801020 Labos Debugging page 4 of B) Question 4 Write a function called draw_house that accepts an integer value size and draws a picture of a house using print statements, 'X' (capital X) and characters and spaces). Precheck results Marked out of 1.00 . The main body of the house is a square with each side having a length equal to size. . The roof of the house starts with an X at the same width as the walls of the house, and each row above that height, the roof is narrower by a single character on each side. The interior of the house and roof are filled with '-' characters. If no parameter is passed, a house with a default size of 5 should be drawn. A house must be at least size 3. If a value less than 3 is passed then nothing should be printed. The faulty solution is: def draw_house(size): if size == 2 or size == 1 or size == 2: return if size % 2 == 8: left - size // 2 print(' '* left + 'XX') else: left = size // 2 print(' ' * left + 'X') for i in range(left, 0, -1): print(''i+'X' + (size - 2* i) + '.' + 'X') print('X' size) for i in range(e, size-2); print('X' + (size-2) * '-' + 'X') print('X'* size) Identify and correct the fault(s). Submit a correct version of the code. For example: Test Result draw_house) X-X X--X Xxxxx X---X X--X draw_house(2) draw_house(9) X---X X----- X------- XXXXXXXXX httpOcadoune 3 A reimoodlemodelattempt.phe Pattempt=1864Semis 145 page=9&scrolog=1827 4002779687594 1801/2020 LaboCebugging page 1 of B) Answer: (penalty regime: 0.0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) Reset answer 1.def draw_house(size): try: if size == or size == 1 or size == 2: return if size % 2 == 0: left = size // 2 print(' '* left + 'XX) else: left = size // 2 print(' ' * left + 'X') for i in range (left, o, -1): print(' fi + x + (size - 2 * i) * '-' + 'X') print('X'* size) print('x' (size-2)'* '.' + 'X') print('X'* size) except TypeError: size = 5 left = size // 2 for i in range(left, size - 2 + i)* '.' + 'X') print('X'* size) for i in range(0, size-2): ..print('x' + (size-2) '.' + 'X') print('Xsize) MKONO NA SASA Precheck Check Precheck only Test Expected Got X draw_house() X X-X X--X ***Error*** Traceback (most recent call last): File "__tester_.python3", line 57, inStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started