Q. Consider following function header


def robot (voltage, state = 'a stiff', action='voom', type = 'Norwegian Blue'):


For the above function, some function calls are being given below. Find the errors in these function call statements :

 
Function call State reason(s) for these calls being invalid
(a) robot()
(b) robot (voltage = 5.0, 'dead)
(c) robot (110, voltage = 220)
(d) robot (actor = 'Harrison Ford')

Answer :-

 
Function call State reason(s) for these calls being invalid
(a) robot() robot() function have not any argument.
(b) robot (voltage = 5.0, 'dead) keyword argument before positional argument.
(c) robot (110, voltage = 220) multiple values provided for voltage; once as positional argument and again as keyword argument.
(d) robot (actor = 'Harrison Ford') action parameter is not defined in robot() function.

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post