Python Institute PCAP-31-03 Exam - Topic 2 Question 78 Discussion
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?
B) print (self.get())
A) print (get(self))
C) print (get())
D) print (self.get (val))
Python Institute PCAP-31-03 Exam - Topic 2 Question 78 Discussion
Actual exam question for
Python Institute's
PCAP-31-03 exam
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?
I'm not entirely sure about this one. The wording of the question is a bit tricky, and I'm not 100% confident in my understanding of how instance methods work in this context. I'll need to review my notes on class definitions and method invocation before I can give a definitive answer.
Okay, I think I've got it. The key here is that the question wants us to use the "show()" method to invoke the "get()" method and output the result. Since "get()" is an instance method, we need to call it on the self object, so the answer is B - print(self.get()).
Hmm, I'm a bit confused here. The question mentions invoking the get() method, but it doesn't specify where that method is defined. Is it a method of the class in the image, or is it a separate function? I'll need to think this through carefully before answering.
This looks like a pretty straightforward question. I think the answer is B - print(self.get()). The question states that we want the show() method to invoke the get() method, and then output the value it returns. Since get() is an instance method, we need to call it on the self object.
Portia
10 months agoKate
10 months agoEzekiel
10 months agoRessie
11 months agoShayne
11 months agoDaron
11 months agoEleonore
11 months agoKattie
11 months agoHelaine
12 months agoRene
12 months agoSusana
12 months agoMariann
12 months agoMyra
12 months agoSage
2 years agoJudy
2 years agoPearlie
2 years agoEileen
2 years agoSimona
2 years agoPortia
2 years agoJesusa
2 years agoErin
2 years agoLindsey
2 years agoCatina
2 years agoDevorah
2 years agoBrett
2 years agoJillian
2 years agoMargot
2 years agoKerry
2 years agoMaia
2 years agoRoselle
2 years agoRoselle
2 years agoSheridan
2 years ago