Advertisements
Advertisements
Question
What all can be possible outputs of the following code?
def myfunc(x=None):
result = ""
if x is None:
result = "No argument given"
elif x == 0:
result = "Zero"
elif 0 < x <= 3:
result = "x is between 0 and 3"
else:
result = "x is more than 3"
return resultCode Writing
Advertisements
Solution
The possible outputs are:
No argument given
Zero
x is between 0 and 3
x is more than 3
For example:
myfunc()→No argument givenmyfunc(0)→Zeromyfunc(2)→x is between 0 and 3myfunc(5)→x is more than 3
shaalaa.com
Is there an error in this question or solution?
