midterm-2-key

# Mark the python statement x rawinput n is equivalent

This preview shows pages 9–13. Sign up to view the full content.

Question 18 [1 mark] The Python statement x = raw_input() + "\n" is equivalent to to A. import sys x = sys.stdin.write() B. import sys x = sys.stdin.writelines() C. import string x = string.split(input()) D. import sys x = sys.stdin.read() E. import sys x = sys.stdin.readline() = ANS Question 19 [1 mark] Consider the following Python function: def otter(x,y): if x: return True else: if y: return True else: return False What is the value of otter(a,b) when a and b are boolean expressions: continued on page 10

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
ENG 1D04 SOLUTIONS 10/14 Question 20 [1 mark] Consider the following Python function: def abs(x): if x < 0: return -x else: return x In which of the following expressions is abs used as a value but not as a rule? Question 21 [1 mark] In which software development phase is pseudo-code useful? Question 22 [1 mark] Consider the Python code for i in range(len(L)): L[i] = i + 1 where the value of L is a list of floats. This code is equivalent to A. while i < len(L): L[i] = i + 1 continued on page 11
ENG 1D04 SOLUTIONS 11/14 B. while 0 <= i and i < len(L): L[i] = i + 1 i = i + 1 C. i = 0 while 0 <= i: i = i + 1 L[i] = i + 1 D. i = 0 while i < len(L): L[i] = i + 1 i = i + 1 = ANS E. i = 0 while i in L: L[i] = i + 1 Question 23 [1 mark] In the graphics.py module used in the book, draw is a(n) Question 24 [1 mark] What is the type of 2.0 ** 100 in Python? continued on page 12

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
ENG 1D04 SOLUTIONS 12/14 Question 25 [1 mark] What is the type of 4 < 0.01 in Python?
This is the end of the preview. Sign up to access the rest of the document.

{[ 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