Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Python Institute Exam PCAP-31-03 Topic 2 Question 78 Discussion

Actual exam question for Python Institute's PCAP-31-03 exam
Question #: 78
Topic #: 2
[All PCAP-31-03 Questions]

The following class definition is given. We want the show () method to invoke the get () method, and then output the value the get () method returns. Which of the invocations should be used instead of XXX?

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

Sage
10 months ago
I'm not sure, but I think C is also a possible answer.
upvoted 0 times
...
Judy
10 months ago
Hmm, this is a tricky one. But I think B) print(self.get()) is the right answer. Gotta love those self-referential method calls!
upvoted 0 times
Pearlie
9 months ago
I would choose C) print(get()) for this one.
upvoted 0 times
...
Eileen
9 months ago
I'm not sure, but I would go with B) print(self.get()).
upvoted 0 times
...
Simona
9 months ago
I think A) print(get(self)) might work too.
upvoted 0 times
...
Portia
10 months ago
I agree, B) print(self.get()) is the correct choice.
upvoted 0 times
...
...
Jesusa
10 months ago
B) print(self.get()) is the way to go. I mean, come on, it's basic object-oriented programming 101.
upvoted 0 times
Erin
9 months ago
Agreed, using self to access the method within the class is the right approach.
upvoted 0 times
...
Lindsey
10 months ago
Yeah, that makes sense. It's the standard way to call a method on an object.
upvoted 0 times
...
Catina
10 months ago
I think B) print(self.get()) is the correct invocation.
upvoted 0 times
...
...
Devorah
11 months ago
Haha, I'm going to go with C) print(get()). Just kidding, that's obviously wrong. It's gotta be B) print(self.get()).
upvoted 0 times
...
Brett
11 months ago
Definitely B) print(self.get()). The 'self' keyword is used to refer to the instance of the class, so that's the way to access the get() method.
upvoted 0 times
...
Jillian
11 months ago
I agree with Sheridan, because self.get() is the correct way to invoke the get() method.
upvoted 0 times
...
Margot
11 months ago
I think the correct answer is B) print(self.get()). That's the standard way to call a method on an object in Python.
upvoted 0 times
Kerry
10 months ago
I see, thanks for clarifying. B) print(self.get()) it is then.
upvoted 0 times
...
Maia
10 months ago
No, A) print(get(self)) would not work because get() is a method of the object, so we need to use self.get().
upvoted 0 times
...
Roselle
10 months ago
But what about A) print(get(self))? Wouldn't that work as well?
upvoted 0 times
...
Roselle
10 months ago
I agree, B) print(self.get()) is the correct way to call a method on an object.
upvoted 0 times
...
...
Sheridan
11 months ago
I think the answer is B.
upvoted 0 times
...

Save Cancel