Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

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 (?) , you can switch to a simple comment.
Switch to a voting comment New
anjuvinayan
Highly Voted 4 years, 4 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 4 years, 8 months ago
So the correct answer should be A?
upvoted 12 times
FR99
3 years, 7 months ago
Yes, answer is "A"
upvoted 2 times
...
...
TheFivePips
Most Recent 4 months, 2 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
1 year, 6 months ago
Selected Answer: A
Answer is A.
upvoted 1 times
...
Suvabrata
1 year, 10 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
1 year, 11 months ago
Selected Answer: A
A. yes, and it can differentiate its behavior between the regular launch and import
upvoted 1 times
...
Anton2020
2 years, 5 months 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, 1 month ago
Answer is A
upvoted 2 times
...
Spectra
3 years, 7 months ago
A is the answer
upvoted 3 times
...
imsaad
3 years, 9 months ago
A is the answer
upvoted 3 times
...
SophieSu
4 years, 5 months ago
I feel like C would be the correct answer
upvoted 5 times
FR99
3 years, 7 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 ...