Question: Python Part one: single-answer multiple-choice items3 points for each question, 18 points in total 1The sign for multiple line comments of Python language is A.
Python
Part one: single-answer multiple-choice items3 points for each question, 18 points in total
1The sign for multiple line comments of Python language is A. // B. # C. D. \\
2def print(a, b): if a < b: return a, b else: return b, a x, y = 4, 2; if x < y: print(x, y) else: print(y, x) The result of the program is A. 4, 2 B. 2, 4 C. None D. syntax error
3 class A: def __init__(self, a, b): self.a = b def ab(self, a): self.b = a a = A(1, 2) After we running the program, the value for a.a and a.b is A. 1, 2 B. 2, 1 C. 1, AttributeError: 'A' object has no attribute 'b' D. 2, AttributeError: 'A' object has no attribute 'b'
4def f(a, b): a = 10 for i in range(len(b)): if i % 2 != 0: b[i] = a a = 5; b = [1, 2, 3, 4, 5]; f(a, b) After we running the program, the value for a and b is A. 5, [1, 2, 3, 4, 5] B. 10, [1, 2 3, 4, 5] C. 10, [1, 10, 3, 10, 5] D. 5, [1, 10, 3, 10, 5]
5For binary input and output, write the integer 12 to the file. Which one is right ? A. pickle.dump(str(12), file) B. pickle.dump(12, file) C. pickle.load(str(12), file) D. pickle.load(12, file)
6The result of the following program is try: lst = [[1, 2, 3, 4], 2] print(lst[2]) except IndexError: print(index out of bound) else: print(nothing is wrong) finally: print(now is ok) A. index out of bound now is ok B. index out of bound C. nothing is wrong D. nothing is wrong now is ok
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
