Certified Associate in Python Programming Questions and Answers
Question 5
What is the expected behavior of the following code?
Options:
A.
it outputs 1
B.
it outputs 2
C.
the code is erroneous and it will not execute
D.
it outputs 3
Answer:
B
Question 6
The first parameter of each method:
Options:
A.
holds a reference to the currently processed object
B.
is always set to None
C.
is set to a unique random value
D.
is set by the first argument's value
Answer:
D
Explanation:
Explanation:
The first argument of every class method, including init, is always a reference to the current instance of the class. By convention, this argument is always named self. In the init method, self refers to the newly created object; in other class methods, it refers to the instance whose method was called
Question 7
What is the expected output of the following code?
Options:
A.
21
B.
2
C.
3
D.
12
Answer:
A
Question 8
Which of the following expression evaluate to True? (Select two answers)