1. Read the file print() vs retum available in the LAB1 Assignment on Canvas. 2. Download...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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] 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]
Expert Answer:
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Posted Date:
Students also viewed these programming questions
-
Write a Scheme function that takes a list as a parameter and returns a list identical to the parameter list except with the second top-level element removed. If the given list does not have two...
-
Write a Scheme function that takes a list as a parameter and returns a list identical to the parameter except the last element has been deleted.
-
If a number is divisible by 3 and 5, then the number is divisible by 15. Determine whether the statement is true or false. Modify each false statement to make it a true statement.
-
Necked Amber purchased a bond for $1,038.90 exactly two years ago. At that time, the bond had a maturity of five years and a coupon rate of 10% (paid semi-annually). Assuming the rates below are the...
-
The American Board of Internal Medicine (ABIM) has taken some sort of disciplinary action against 140 doctors who cheated on their ABIM certification exams. Documents in a now-settled case included...
-
Refer to Gazelle Corporation's financial statements and related information in Problem 16-3B. Required Prepare a complete statement of cash flows; report its operating activities according to the...
-
Explain the value of finance and budgeting systems .
-
Hicks Corporation seeks your assistance in developing cash and other budget information for August, September, and October. At July 30, the company had cash of $5,500, accounts receivable of...
-
List the three U.S. comparative advantagesand briefly discuss theimplications of each 1. Technology advantage: 2. Large domestic market: 3. Large area in temperate zone List the three U.S....
-
1. Fill the missing values in the table and show the calculations. 2. Provide a detailed description of the Fresnel Zone and how it is affecting the condition of the link between the two sites. 3....
-
An unknown bacterium is tested for tryptophanase activity. The media used to test the organism was prepared according to the following recipe: To 1000 mL distilled water add: 5 g Lysine 1 g Glucose...
-
On cold day the air outside temperature is 0 degrees Celsius and the ground under the house is 1 0 Celsius. The optimal inside temperature for little pig habitation is 2 0 Celsius. Pig Number 2 has...
-
Two metal spheres, each of mass 14 g and initially at rest, are dropped from a height of 9 m in an evacuated chamber. One sphere has a charge of +70 C, and the other has a charge -70 C. Find the...
-
3. A typical capacitor in an MP3 player has C = 9 F. If a charge 31 C is placed on the plates, what is the voltage across the capacitor? 4. Two capacitors with C 1 = 3.5 F and C 2 = 22.5 F are...
-
A typical lightbulb in your house is rated 50 W, which means that the bulb dissipates 50 W when connected to a DC voltage of 115 V. (a) What is the current through the lightbulb? (b) If the voltage...
-
4. A turtle starts from rest and moves with a constant acceleration along straight ditch. He starts his stopwatch as he passes a fence post and notes that it takes him 10 s to reach a pine tree 10 m...
-
A compressive load of 80,000 lb is applied to a bar with circular section 0.75 in diameter and a length of 8 in. if the modulus of elasticity of the bar material is 10,000 ksi and the Poisson's ratio...
-
What types of inventory issues Starbucks might reflect upon at the end of each year? The mission of Starbucks is to inspire and nurture the human spiritone person, one cup, and one neighborhood at a...
-
By changing the potential function, it is possible to prove different bounds for splaying. Let the weight function W(i) be some function assigned to each node in the tree, and let S(i) be the sum of...
-
a. Prove that 7 comparisons are required to sort 5 elements using any comparison based algorithm. b. Give an algorithm to sort 5 elements with 7 comparisons.
-
Implement the contains routine for MyLinkedList.
-
A reversible heat engine working between two thermal reservoirs at \(875 \mathrm{~K}\) and \(315 \mathrm{~K}\) drives a reversible refrigerator which operates between the same \(315 \mathrm{~K}\)...
-
2 kg of water at \(80^{\circ} \mathrm{C}\) is mixed adiabatically with \(3 \mathrm{~kg}\) of water at \(30^{\circ} \mathrm{C}\) in a constant pressure process of 1 atmosphere. Find the increase in...
-
A heat engine operating between two reservoirs at \(1000 \mathrm{~K}\) and \(300 \mathrm{~K}\) is used to drive a heat pump which extracts heat from the reservoir at \(300 \mathrm{~K}\), at a rate...
Study smarter with the SolutionInn App