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

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

If you need a function that does nothing, what would you use instead of XXX? (Choose two.)

  • A. pass
  • B. return
  • C. exit
  • D. None
Show Suggested Answer Hide Answer
Suggested Answer: AD 🗳️
Reference:
https://www.pythoncentral.io/python-null-equivalent-none/

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Oracleist
2 months, 4 weeks ago
I think A,D return will have the same effect of None, but return will made a return to a function call, that is different then do nothing as the question ask.
upvoted 1 times
...
TheFivePips
4 months, 4 weeks ago
This is a dumb question. return, pass, and None will all work. It kinda just depends on how you want to do it. pass is probably to best to use, since it pretty clearly indicates youre just moving on. return will implicitly return None, and so will None. I guess Id give the edge to None over return just because its slightly more clear but its a function that does nothing, who cares?
upvoted 1 times
...
Acid_Scorpion
7 months ago
Selected Answer: AB
A & B is correct
upvoted 1 times
...
EltonAuguston
11 months ago
but using return suggests that the function is intended to produce a result, even if it is not explicitly defined. so its AnD
upvoted 3 times
...
wedlive
1 year ago
AB You can use the pass keyword to create a function that does nothing and just returns control to the caller, or you can use the return statement without any value to exit the function and return None. The exit function is used to terminate the program, not to create a function that does nothing.
upvoted 1 times
...
ryanzou
1 year, 1 month ago
Selected Answer: AB
AB are correct
upvoted 1 times
...
Mallie
1 year, 4 months ago
Selected Answer: AB
Pass & Return are the preferred solutions used on the Edube course A & B
upvoted 2 times
...
Adeshina
1 year, 4 months ago
A. pass D. None The pass and None keywords can be used to define a function that does nothing. The pass keyword can be used as a placeholder for code that has not yet been implemented, or as a way to create an empty block of code. The None keyword represents the null value and can be used to indicate that a function does not return a value. In the case of the idler function, using either pass or None as the body of the function will cause the function to do nothing when it is called.
upvoted 3 times
...
agus007
1 year, 6 months ago
The answer should be AB, pass does nothing. return is always implicit, so make it explicit will do the same, nothing.
upvoted 1 times
...
PremJaguar
1 year, 9 months ago
Selected Answer: AB
should be AB because return is automatic and pass does nothing
upvoted 1 times
...
666_m
1 year, 12 months ago
A&D is correct
upvoted 1 times
...
macxsz
2 years ago
Selected Answer: AD
A. pass D. None
upvoted 2 times
...
rocky48
2 years, 1 month ago
Selected Answer: AD
Options : A,B,C & D will all return the same empty result on the console prompt. But None is over-writing the output and exit will exit the function, thus i would go with A & D.
upvoted 1 times
rocky48
2 years, 1 month ago
A. pass - Will do nothing B. return - Will return nothing C. exit - Will exit the program D. None - "None" refers exactly to the intended functionality - it is nothing, and has no behaviour.
upvoted 3 times
...
...
Backy
2 years, 2 months ago
Answer should be AB D would work but any constant like None, True, False, 3, 5.333 would work but this is not specific to a function, you could place them at the shell prompt and it would work the same D should not be even on the list when B is included, B takes the precedence over D
upvoted 3 times
rocky48
2 years, 1 month ago
A. pass - Will do nothing B. return - Will return nothing C. exit - Will exit the program D. None - "None" refers exactly to the intended functionality - it is nothing, and has no behaviour. A & D seem to be fine.
upvoted 1 times
Backy
2 years ago
I think you do not have a clue about basics of programming. If you put just 'None' on the line it will be translated into 'None' followed by 'return' anyway. Any function will always have 'return' at the end, it is implied. So by definition, if a function has only 'return' then it does nothing because 'return' is always added anyway and it is redundant. Most importantly, the actual exam would never include a question with such overlapping answers
upvoted 2 times
...
...
...
smarty_arse
2 years, 3 months ago
Correct answers
upvoted 1 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 ...