A Python module named pymod.py contains a variable named pyvar.
Which of the following snippets will let you access the variable? (Select two answers)
Suggested Answer: A, D
Get Premium PCAP-31-03 Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
25 comments · newest first
KI
Kimbery
11 months ago
Definitely D, but I’m not sure about C.
NI
Nieves
11 months ago
I think option C is also correct!
CA
Carissa
11 months ago
You can access pyvar with option D.
NE
Nell
12 months ago
No way, option B is totally wrong.
FI
Filiberto
12 months ago
Wait, can you really import like that? Sounds off.
SC
Scarlet
1 year ago
I’m a bit confused about option D; I remember something about accessing variables with the module name, but I’m not sure if that’s the correct syntax.
MI
Milly
1 year ago
I practiced a similar question where we had to import a variable, and I think using `from pymod import pyvar` is the way to go.
MA
Margarett
1 year ago
I'm not entirely sure, but I feel like option B looks wrong because it has an assignment in the import statement, which doesn't seem right.
RU
Ruthann
1 year ago
I think I remember that to access a variable from a module, you usually use the `import` statement.
MI
Mickie
1 year ago
Alright, let me think this through step-by-step. We have a module named pymod.py with a variable named pyvar. To access that variable, we either need to import the variable directly (option B) or access it through the module object (option D). Options A and C don't seem to be the correct approach. I'm feeling good about my understanding of this.
MA
Mariann
1 year ago
I'm a little unsure about this one. I know we need to access the variable from the module, but I'm not sure if the syntax in the options is correct. I'll have to double-check the Python import and module access syntax to make sure I'm selecting the right answers.
CH
Christiane
1 year ago
Okay, I've got this. The key is that we need to access the variable from the module, not try to import it directly. So the correct options are B, where we import the variable, and D, where we access it through the module object. I'm feeling confident about this one.
ME
Merri
1 year ago
Hmm, I'm a bit confused. I'm not sure if option A is valid, since it seems to be trying to import the variable directly instead of the module. And option C looks like it's trying to call the variable as a function, which doesn't seem right. I'll have to think this through carefully.
KA
Kathrine
1 year ago
This looks straightforward. I think the correct answers are B and D - importing the variable directly from the module, or accessing it through the module object.
AV
Avery
1 year ago
I think B) is definitely wrong because you can't assign a value when importing
RO
Robt
1 year ago
I'm not sure, but I think A) and D) are the correct answers
AN
Annelle
1 year ago
I disagree, I believe the correct answers are B) and D)
BR
Brett
1 year ago
I think the correct answers are A) and C)
VE
Veda
1 year ago
Option D is the correct way to access the variable. You need to import the module and then use the module name to access the variable.
SH
Shawnta
1 year ago
Oh, I see. Thanks for clarifying.
VI
Vivan
1 year ago
C) from pymod import pyvar pyvar ()
RE
Reita
1 year ago
No, option D is the correct way to access the variable.
SH
Sharen
1 year ago
I think option A is correct.
MA
Mabelle
1 year ago
B) from pymod import pyvar = 1
ES
Estrella
1 year ago
A) import pyvar from pymod pyvar = 1