hiexam
python-institute · PCAP · Q606 · multiple_response · topic_1

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

Assuming that the code below has been executed successfully, which of the expressions evaluate to True? (Choose two.) //IMG//
  • A.len(Class.__dict__) == 1
  • B.'data' in Class.__dict__
  • C.'var' in Class.__dict__
  • D.'data' in Object.__dict__
Explanation
There is a typo in answer C. "var" should be capitalized "Var": class Class: Var = data = 1 def __init__(self,value): self.prop = value Object = Class(2) print(len(Class.__dict__) == 1) # False print("data" in Class.__dict__) # True print("Var" in Class.__dict__) # True print("data" in Object.__dict__) # False print(Class.__dict__) print("*************") print(Object.__dict__)

Reference: examtopics_top_comment

Practice with progress tracking

Sign in to track wrong answers, get spaced-repetition reminders, and run timed exam mode.