Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribed

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, in draw_house() TypeError: draw_house() missing 1 required positional argument: 'size' X--- X--- X--- - Lab04Exception Jump to... Labo6Sorting hhilpaaleidum audiane remoodle.mod cuvattempt.ple attempt=18645cmid=14&page=9&scrolece=1827.400877968754

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

Step: 3

blur-text-image

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

Implementing Ai And Machine Learning For Business Optimization

Authors: Robert K Wiley

1st Edition

B0CPQJW72N, 979-8870675855

More Books

Students also viewed these Databases questions

Question

Explain the forces that influence how people handle conflict

Answered: 1 week ago