def getMonth(m): if m<1 or m>12: raise ValueError("Invalid") print(m) getMonth(6)
a) ValueError
b) Invalid
c) 6
d) ValueError(“Invalid”)
def getMonth(m): if m<1 or m>12: raise ValueError("Invalid") print(m) getMonth(6)
a) ValueError
b) Invalid
c) 6
d) ValueError(“Invalid”)
You must be logged in to post a comment.
c
Explanation: In the code shown above, since the value passed as an argument to the function is between 1 and 12 (both included), hence the output is the value itself, that is 6. If the value had been above 12 and less than 1, a ValueError would have been thrown.