Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PYTHON Consider the following code fragment (assumed to be in an otherwise corre

ID: 3738389 • Letter: P

Question

PYTHON Consider the following code fragment (assumed to be in an otherwise correct program) shared-max = 200 def get-max(self): def set max(self, new.max): return self.shared max sharedmax new max self Assume there are no omitted statements within this fragment- you see everything. Check the true statements (may be more than one): Both methods refer to an instance attribute, self shared_ max Both methods refer to the static attribute, MyClass shared max. The mutator refers to an instance attribute, self shared_max, while the accessor refers to the static attribute, MyClass shared max. Question 262 pts Consider the following code segment. It is supposed to count the number of digits (0-9) in a string, text. count = 0 for char in text : count count + 1 What line of code should be placed in the blank to achieve this goal? if text[char] "0" and text[char] "9": >-

Explanation / Answer

1.
Both methods refer to the static attribute, MyClass.shared_max
The mutator refers to an instance attribute, self.shared_max, while the accessor refers to the static attribute, My.shared_max

2.
if char >= "0" and char <="9":
if text >= "0" and char <="9":

3.
Each instance of a class has its own set of data attributes
Starting an attribute name with two underscores will hide the attribute from code outside the class