midterm-2-key

A true b false ans question 3 1 mark no matter what

• Notes
• 14

This preview shows 2 out of 6 pages.

A. True. B. False. = ANS Question 3 [1 mark] No matter what statements are included in the body of a for loop, a for loop is never nonterminating, i.e., it never runs forever. Is this statement true or false? A. True. B. False. = ANS Question 4 [1 mark] Consider the following two Python functions: def f1(x): return (x ** 10) + (2 * x) - 5 def f2(x): print (x ** 10) + (2 * x) - 5 What is the value of f1(3) == f2(3) ? A. True . B. False . = ANS continued on page 3

Subscribe to view the full document.

ENG 1D04 SOLUTIONS 3/14 Question 5 [1 mark] When the Python code x = 19 def fun(x): x = 31 return x print x is executed, 19 is printed. Is this statement true or false? A. True. = ANS B. False. Question 6 [1 mark] If s is of type str , m and n are of type int , and m < n and n <= len(s) are true, then s[m:n] equals s[m] + s[m + 1] + ... + s[n - 1] . Is this statement true or false? A. True. = ANS B. False. Question 7 [1 mark] The Python while statement defines a definite loop. Is this statement true or false? A. True. B. False. = ANS continued on page 4
ENG 1D04 SOLUTIONS 4/14 Question 8 [1 mark] Which great computer scientist is famous for using the motto “Calculemus!”? A. Donald Knuth. B. Malcolm X. C. George Boole. D. Alan Turing. E. Gottfried Leibniz. = ANS Question 9 [1 mark] The largest machine integer in the twos-complement representation of 6-bit machine integers is represented by Question 10 [1 mark] Which of the following statements about exceptions is false? continued on page 5

Subscribe to view the full document.

ENG 1D04 SOLUTIONS 5/14
You've reached the end of this preview.

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern