PCAPga : Certified Associate in Python Programming : Part 06
-
Assuming that the following piece of code has been executed successfully, which of the expressions evaluate to True? (Choose two.)
- isinstance (obj_b,A)
- A.VarA == 1
- obj_a is obj_aa
- B.VarA == 1
-
Assuming that the code below has been executed successfully, which of the expressions evaluate to True? (Choose two.)
- len(Class.__dict__) == 1
- ‘data’ in Class.__dict__
- ‘var’ in Class.__dict__
- ‘data’ in Object.__dict__
-
A property that stores information about a given class’s super-classes is named:
-
__upper__
-
__super__
-
__ancestors__
-
__bases__
Explanation:
Reference: https://www.python-course.eu/python3_inheritance.php
-
-
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.)
- self.queue.append(self.get_last() + 1)
- self.queue.append(get_last() + 1)
- self.queue.append(self.queue[-1] + 1)
- queue.append(self.get_last() + 1)
-
What is the expected output of the following code?
- a
- c
- an exception is raised
- b
Explanation:
-
What is the expected output of the following code if there is no file named non_existing_file inside the working directory?
- 1 2 4
- 1 2 3 4
- 2 4
- 1 3
-
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?
- the length of the first line from the file
- -1
- the number of lines contained inside the file
- the length of the last line from the file
-
What is the expected behavior of the following code?
- it outputs [1, 3]
- the code is erroneous and it will not execute
- it outputs [3, 1]
- it outputs [4, 2, 0]
Explanation:
-
Assuming that the following code has been executed successfully, which of the expressions evaluate to True? (Choose two.)
- b() == 4
- a != b
- a is not None
- a() == 4
-
What is the expected output of the following code?
- 3
- 5
- 4
- an exception is raised
Explanation:
-
Which of the following lambda definitions are correct? (Choose two.)
- lambda x,y: (x,y)
- lambda x,y: return x//y – x%y
- lambda x,y: x//y – x%y
- lambda x,y = x//y – x%y
-
Which of the following statements are true? (Choose two.)
- if invoking open () fails, an exception is raised
- open () requires a second argument
- open () is a function which returns an object that represents a physical file
- instd, outstd. errstd are the names of pre-opened streams
-
What is the expected behavior of the following code?
- the code is erroneous and it will not execute
- it outputs 1
- it outputs -1
- it outputs 0
Explanation:
Subscribe
0 Comments
Newest