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 21 discussion

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

Can a module run like regular code?

  • A. yes, and it can differentiate its behavior between the regular launch and import
  • B. it depends on the Python version
  • C. yes, but in cannot differentiate its behavior between the regular launch and import
  • D. no, it is not possible; a module can be imported, not run
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

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
anjuvinayan
Highly Voted 4 years, 12 months ago
Answer is A. yes, and it can differentiate its behavior between the regular launch and import Module have 2 users.One is the creator and other is the module users.The creator can execute his module and check the functionality using __name__ variable.Normal module users can execute the module by using import
upvoted 25 times
...
locloc91
Highly Voted 5 years, 3 months ago
So the correct answer should be A?
upvoted 12 times
FR99
4 years, 2 months ago
Yes, answer is "A"
upvoted 2 times
...
...
TheFivePips
Most Recent 11 months, 4 weeks ago
In Python, when a module is run, the code in the module is executed. However, Python provides a built-in variable called __name__ that allows a module to determine whether it is being run as the main program or if it is being imported into another module.
upvoted 1 times
...
Soye_1001
2 years, 2 months ago
Selected Answer: A
Answer is A.
upvoted 1 times
...
Suvabrata
2 years, 5 months ago
Correct answer is A. A module can be simple python file with .py extension and so can be run
upvoted 1 times
...
macxsz
2 years, 7 months ago
Selected Answer: A
A. yes, and it can differentiate its behavior between the regular launch and import
upvoted 1 times
...
Anton2020
3 years ago
This video also has a practical example of it around 10 minutes 30 seconds: https://www.youtube.com/watch?v=jO6qQDNa2UY He makes sure the function is only called when this file is the main file (i.e. not imported from somewhere else).
upvoted 2 times
...
PythonPuhal
3 years, 8 months ago
Answer is A
upvoted 2 times
...
Spectra
4 years, 2 months ago
A is the answer
upvoted 3 times
...
imsaad
4 years, 4 months ago
A is the answer
upvoted 3 times
...
SophieSu
5 years ago
I feel like C would be the correct answer
upvoted 5 times
FR99
4 years, 2 months ago
Answer is definitely "A"
upvoted 2 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 ...