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 PCAP-31-03 Exam - Topic 5 Question 92 Discussion

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)
A) import pyvar from pymod pyvar = 1 and D) import pymod pymod.pyvar = 1
B) from pymod import pyvar = 1
C) from pymod import pyvar pyvar ()

Python Institute PCAP-31-03 Exam - Topic 5 Question 92 Discussion

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

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)

Show Suggested Answer Hide Answer
Suggested Answer: A, D

Contribute your Thoughts:

0/2000 characters
Kimbery
9 months ago
Definitely D, but I’m not sure about C.
upvoted 0 times
...
Nieves
9 months ago
I think option C is also correct!
upvoted 0 times
...
Carissa
9 months ago
You can access pyvar with option D.
upvoted 0 times
...
Nell
10 months ago
No way, option B is totally wrong.
upvoted 0 times
...
Filiberto
10 months ago
Wait, can you really import like that? Sounds off.
upvoted 0 times
...
Scarlet
10 months 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.
upvoted 0 times
...
Milly
10 months 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.
upvoted 0 times
...
Margarett
11 months 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.
upvoted 0 times
...
Ruthann
11 months ago
I think I remember that to access a variable from a module, you usually use the `import` statement.
upvoted 0 times
...
Mickie
11 months 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.
upvoted 0 times
...
Mariann
11 months 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.
upvoted 0 times
...
Christiane
11 months 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.
upvoted 0 times
...
Merri
12 months 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.
upvoted 0 times
...
Kathrine
12 months 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.
upvoted 0 times
...
Avery
1 year ago
I think B) is definitely wrong because you can't assign a value when importing
upvoted 0 times
...
Robt
1 year ago
I'm not sure, but I think A) and D) are the correct answers
upvoted 0 times
...
Annelle
1 year ago
I disagree, I believe the correct answers are B) and D)
upvoted 0 times
...
Brett
1 year ago
I think the correct answers are A) and C)
upvoted 0 times
...
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.
upvoted 0 times
Shawnta
1 year ago
Oh, I see. Thanks for clarifying.
upvoted 0 times
...
Vivan
1 year ago
C) from pymod import pyvar pyvar ()
upvoted 0 times
...
Reita
1 year ago
No, option D is the correct way to access the variable.
upvoted 0 times
...
Sharen
1 year ago
I think option A is correct.
upvoted 0 times
...
Mabelle
1 year ago
B) from pymod import pyvar = 1
upvoted 0 times
...
Estrella
1 year ago
A) import pyvar from pymod pyvar = 1
upvoted 0 times
...
...

Save Cancel