PCAP
Free trial
Verified
Question 1
What will be the value of the i variable when the while e loop finishes its execution?
- A: 1
- B: 0
- C: 2
- D: the variable becomes unavailable
Question 2
What is the expected output of the following snippet?
- A: 3
- B: 1
- C: 2
- D: the code is erroneous
Question 3
What is true about Python class constructors? (Choose two.)
- A: there can be more than one constructor in a Python class
- B: the constructor must return a value other than None
- C: the constructor is a method named __init__
- D: the constructor must have at least one parameter
Question 4
Assuming that the following piece of code has been executed successfully, which of the expressions evaluate to True? (Choose two.)
- A: isinstance (obj_b,A)
- B: A.VarA == 1
- C: obj_a is obj_aa
- D: B.VarA == 1
Question 5
Assuming that the code below has been executed successfully, which of the expressions evaluate to True? (Choose two.)
- A: len(Class.__dict__) == 1
- B: 'data' in Class.__dict__
- C: 'var' in Class.__dict__
- D: 'data' in Object.__dict__
Question 6
A property that stores information about a given class's super-classes is named:
- A: __upper__
- B: __super__
- C: __ancestors__
- D: __bases__
Question 7
Which of the following lines of code will work flawlessly when put independently inside the add_new() method in order to make the snippet's output equal to [0,
1, 2]? (Choose two.)
- A: self.queue.append(self.get_last() + 1)
- B: self.queue.append(get_last() + 1)
- C: self.queue.append(self.queue[-1] + 1)
- D: queue.append(self.get_last() + 1)
Question 8
What is the expected output of the following code?
- A: a
- B: c
- C: an exception is raised
- D: b
Question 9
What is the expected output of the following code if there is no file named non_existing_file inside the working directory?
- A: 1 2 4
- B: 1 2 3 4
- C: 2 4
- D: 1 3
Question 10
What is the expected output of the following code if the file named existing_text_file is a non-zero length text file located inside the working directory?
- A: the length of the first line from the file
- B: -1
- C: the number of lines contained inside the file
- D: the length of the last line from the file
Question 11
What is the expected behavior of the following code?
- A: it outputs [1, 3]
- B: the code is erroneous and it will not execute
- C: it outputs [3, 1]
- D: it outputs [4, 2, 0]
Question 12
Assuming that the following code has been executed successfully, which of the expressions evaluate to True? (Choose two.)
- A: b() == 4
- B: a != b
- C: a is not None
- D: a() == 4
Question 13
Assuming that the following snippet has been successfully executed, which of the equations are True? (Choose two.)
- A: len(a) == len (b)
- B: b [0] +1 ==a [0]
- C: a [0] == b [0]
- D: a [0] + 1 ==b [0]
Question 14
What is the expected output of the following code?
- A: 3
- B: 5
- C: 4
- D: an exception is raised
Question 15
Which of the following lambda definitions are correct? (Choose two.)
- A: lambda x,y: (x,y)
- B: lambda x,y: return x//y - x%y
- C: lambda x,y: x//y - x%y
- D: lambda x,y = x//y - x%y
Question 16
Which of the following statements are true? (Choose two.)
- A: if invoking open () fails, an exception is raised
- B: open () requires a second argument
- C: open () is a function which returns an object that represents a physical file
- D: instd, outstd. errstd are the names of pre-opened streams
Question 17
What is the expected behavior of the following code?
- A: the code is erroneous and it will not execute
- B: it outputs 1
- C: it outputs -1
- D: it outputs 0
Question 18
Which of the following snippets will execute without raising any unhandled exceptions? (Choose two.)
A.
B.
C.
D.
Question 19
Which of the following expressions evaluate to True? (Choose two.)
- A: '8' + '8' !=2 * '8'
- B: 'xYz'.lower() > 'XY'
- C: float('3.14') == str('3.' + '14')
- D: 121 + 1 ==int('1' + 2 * '2')
Question 20
What is the expected behavior of the following code?
- A: it raises an exception
- B: it outputs 3
- C: it outputs 1
- D: it outputs 6
Question 21
What is the expected behavior of the following code?
- A: the code is erroneous and it will not execute
- B: it outputs 2.0
- C: it outputs 2.5
- D: it outputs 3.0
Question 22
What is the expected behavior of the following code?
- A: it outputs [4, 2]
- B: it outputs [2, 4]
- C: it outputs [0, 1, 2, 3, 4]
- D: the code is erroneous and it will not execute
Question 23
The bases property contains:
- A: base class location (addr)
- B: base class objects (class)
- C: base class names (str)
- D: base class ids (int)
Question 24
Assuming that the following snippet has been successfully executed, which of the equations are False? (Choose two.)
- A: len(a)== len (b)
- B: a [0]-1 ==b [0]
- C: a [0]== b [0]
- D: b [0] - 1 ==a [0]
Question 25
What is the expected behavior of the following code?
- A: it outputs 0
- B: it raises an exception
- C: it outputs 1
- D: it outputs 2
Free preview mode
Enjoy the free questions and consider upgrading to gain full access!