Learn to Program: The Fundamentals - Week 5 Exercise Answers
Learn to Program: The Fundamentals - Week 5 Exercise Score of 13.75 out of 14.00 Open up IDLE and try out all the code as you do the exercise! Question 1 Select the expression(s) that evaluate to True . Your Answer Score Explanation [1, 2, 3] in len('mom') Correct 0.25 len('mom') in [1, 2, 3] Correct 0.25 int('3') in [len('a'), len('ab'), len('abc')] Correct 0.25 '3' in [1, 2, 3] Correct 0.25 Total 1.00 / 1.00 Question Explanation Evaluate each of these expressions in the Python shell and, if the results surprise you, you should also evaluate each subexpression. Question 2 Consider this code: def mystery(s): i = 0 result = '' while not s[i].isdigit(): result = result + s[i] i = i + 1 return result Select the function call(s) that result in an error. Your Answer Score Explanation mystery('abc') Correct 0.25 mystery('abc123...