Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Read the file print() vs retum available in the LAB1 Assignment on Canvas. 2. Download the starter code file from the LAB1 Assignment
1. Read the file print() vs retum available in the LAB1 Assignment on Canvas. 2. Download the starter code file from the LAB1 Assignment on Canvas. Do not change the function names or given started code on your script 3. A doctest is provided as an example of code functionality. Getting the same result as the doctest does not guarantee full credit (See Appendix for a quick introduction to the doctest module). You are responsible for debugging and testing your code with enough data. 4. Each function must return the output (Do not use print in your final submission, otherwise your submissions will receive a-1 point deduction) 5. Do not include test code outside any function in the upload. Printing unwanted or ill-formatted data to output will cause the test cases to fail. Remove all your testing code before uploading your file (You can also remove the doctest). 6. Do not include the input() function in your submission. |GOAL| Using your text editor, write the function sumSquares(aList). The function takes a list as an input and returns (not prints) the sum of the squares of the all the numbers which absolute value is divisible by 3. If an element in the list is not a number, the function should ignore the value and continue. When the function receives an input that is not a list, code should return an error message to the user. Hints: review the type() or isinstance() methods 10 def sumSquares(al ist): 11 12 13 14 error" > suiSquares('5') "error >>> sumSquares (6.15) 15 16 17 "error" 18 >>> sumSquares([1,5,-3,5,9,8,4]) 19 90 >>> sumSquares (['3',5,-3,5,9.0,8,4, Hello']) 20 21 90.0 22 23 %23 YOU CODE STARTS HERE 24 if type(alist) is not list: File "C:\Users\guo_h\Desktop\cmpsc132\1ab1\sumSquare.py", 1ine 24 25 return 'error 26 27 sun 0.0 for el in aList: if type(el) in (int, float]: sum el el 28 29 30 I 31 32 return sum 33 34 35 36 37 38 File "C:\Users \guo_h\Desktop\cmpsc132\labl\sumSquare.py", line 24 if type(alist) is not 1ist: IndentationError: unindent does not match any outer indentation level [Finished in 0.3s]
Step by Step Solution
★★★★★
3.45 Rating (158 Votes )
There are 3 Steps involved in it
Step: 1
Python program def sumSquaresaList if not is...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