Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam PCAP All Questions

View all questions & answers for the PCAP exam

Exam PCAP topic 1 question 73 discussion

Actual exam question from Python Institute's PCAP
Question #: 73
Topic #: 1
[All PCAP Questions]

What is the expected output of the following snippet?

  • A. True False
  • B. True True
  • C. False False
  • D. False True
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
WillyNilly69
Highly Voted 4 years, 5 months ago
serious capitalization typos, however the correct answer is B. class X: pass class Y(X): pass class Z(Y): pass x = Z() z = Z() print(isinstance (x, Z), isinstance (z, X)) >>>True True
upvoted 30 times
...
apextek1
Highly Voted 4 years, 8 months ago
Should be B
upvoted 9 times
...
zantrz
Most Recent 10 months ago
B True True. In this code: There are three classes: X, Y, and Z. Class Y inherits from class X, and class Z inherits from class Y. Two instances, x and z, are created as objects of class Z. The isinstance function is then used to check the types of these instances. Here's the breakdown: x = Z(): This line creates an instance of class Z and assigns it to the variable x. z = Z(): This line creates another instance of class Z and assigns it to the variable z. Now, let's look at the print statement: print(isinstance(x, Z), isinstance(z, X)): This line checks if x is an instance of Z (which it is, as x was instantiated from class Z). It also checks if z is an instance of X (which it is, as Z inherits from Y and Y inherits from X). So, the output of this code will be: B True True.
upvoted 4 times
...
Mallie
1 year, 11 months ago
Selected Answer: B
Answer is B....if it wasn't for the typos.
upvoted 1 times
...
Jnanada
2 years, 3 months ago
Should be B
upvoted 1 times
...
palagus
2 years, 6 months ago
Selected Answer: B
The answer is B
upvoted 1 times
...
macxsz
2 years, 6 months ago
Selected Answer: B
B. True True
upvoted 1 times
...
Norasit
2 years, 7 months ago
I try to focus on x, X, z, Z. There is no any correct answer.
upvoted 1 times
...
mbacelar
2 years, 7 months ago
Selected Answer: B
True True
upvoted 1 times
...
rocky48
2 years, 8 months ago
Selected Answer: B
If you do: class X: pass class Y(X): pass class Z(Y): pass x = Z() z = Z() print(isinstance(x,Z), isinstance(z,X)) >> True True So B is the answer
upvoted 1 times
...
TheNetworkStudent
2 years, 8 months ago
Selected Answer: B
True True indeed, tested it and that's the result when all typos are corrected. B is correct
upvoted 1 times
...
dougie_fr3sh
2 years, 11 months ago
Please fix these typo's.
upvoted 1 times
...
Het_is_je_boy
4 years, 3 months ago
Should be NameError: name 'x' is not defined.
upvoted 2 times
Het_is_je_boy
4 years, 3 months ago
If you do: class X: pass class Y(X): pass class Z(Y): pass x = Z() z = Z() print(isinstance(x,Z), isinstance(z,X)) you get back True True So B
upvoted 3 times
...
...
imsaad
4 years, 3 months ago
Correct answer is B. True True
upvoted 4 times
...
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.

SaveCancel
Loading ...