PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 126


Assuming that the code below has been executed successfully, which of the expressions evaluate to True? (Choose two.)

Show Answer
Correct Answer: AC

In the Class definition, 'var' is a class variable. Class variables are stored in the class's __dict__, so 'var' in Class.__dict__ evaluates to True. When an instance of the class is created with Object = Class(2), the instance variable 'prop' is added to Object's __dict__. Since only 'prop' is added to Object's __dict__, len(Object.__dict__) == 1 evaluates to True.

Discussion

2 comments
Sign in to comment
macxszOptions: AC
May 4, 2022

A. 'var' in Class.__dict__ C. len(Object.__dict__) == 1

seaverickOptions: AC
Jan 27, 2024

class Class: var=1 def __init__(self,value): self.prop=value Object=Class(2) print('var' in Object.__dict__) print('prop' in Class.__dict__) print('var' in Class.__dict__) print(len(Object.__dict__)==1) print(Class.__dict__) print(Object.__dict__) AC