Answer is A.
The instruction object_1.Variable += 1 creates a new attribute to object_1 and it does not modify class variable 'Variable': object_1.__dict__ ==> {'value':0, 'variable':1}
Since class variable 'Variable' is still 0, object2.variable will be 0, then:
object_2.Variable (0) + object_1.value (1) = 0 + 1 = 1
AttributeError Traceback (most recent call last)
Cell In[15], line 10
8 object_1.Variable += 1
9 object_2 = Class()
---> 10 object_2.value += 1
12 print(object_2.Variable + object_1.value)
AttributeError: 'Class' object has no attribute 'value'
This is what i am getting
'Variable' is a class variable to begin with.
But then, obejct_1.Variable is created and assigned a value of 1. Obejct_2.Variable, which is also an instance variable, has had no value assigned to it.
This section is not available anymore. Please use the main Exam Page.PCAP Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
shawn19810609
2 months, 3 weeks agoshawn19810609
3 months agoshawn19810609
2 months, 3 weeks agoskullomania
1 year, 6 months agobrandonkim76
1 year, 7 months agoSaadThayab
2 years, 1 month agocufta05
1 year, 9 months agomoteruky
1 year, 1 month agosudhanshu1
2 years, 4 months agoMallie
2 years, 3 months agomacxsz
2 years, 11 months agoNoarmy315
3 years, 3 months ago