If you need a function that does nothing, what would you use instead of XXX? (Choose two.)
If you need a function that does nothing, what would you use instead of XXX? (Choose two.)
To create a function in Python that does nothing, you can use 'pass' and 'return'. The 'pass' statement is specifically designed to do nothing and is often used as a placeholder for future code. The 'return' statement with no value also causes the function to do nothing by returning None implicitly. While 'None' can represent the absence of a value, placing it in the body of a function would be interpreted as a literal value and not as a functional placeholder. Hence, the correct choices are 'pass' and 'return'.
but using return suggests that the function is intended to produce a result, even if it is not explicitly defined. so its AnD
Pass & Return are the preferred solutions used on the Edube course A & B
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.
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
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.
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
A. pass D. None
The answers in the dumps are good to remember! The bulk of the exam questions are from these exam dumps. The questions with mistakes in them or missing : etc are in the exam but in the correct answer form, do remember the correct answers as well as the answers with the mistakes in the coding. There are a few questions that are slightly different but you can find the answers from the previous or next question/answers! Hope this helps!
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.
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?
A & B is correct
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.
AB are correct
The answer should be AB, pass does nothing. return is always implicit, so make it explicit will do the same, nothing.
should be AB because return is automatic and pass does nothing
A&D is correct
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.
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.
Correct answers