Consider below given function headers. Identify which of these will cause error and why?

(i) def func(a = 1, b): (ii) def func(a = 1, b, c = 2): (iii) def func(a = 1, b = 1, c = 2): (iv) def func (a = 1, b = 1, c = 2, d):

Option (i) def func(a = 1, b): will cause a syntax error,  because a parameter with a default value cannot be followed by a  parameter without a default value. If a parameter has a default value,  all subsequent parameters must also have default values.

Option (i) If a parameter has a default value,  all subsequent parameters must also have default values.

Option (ii) def func(a = 1, b, c = 2): will also cause a syntax error, for the same reason as option (i).

Option (iii)  def func(a = 1, b = 1, c = 2): is a valid function header, since all three parameters have default values.

Option (iv)  def func(a = 1, b = 1, c = 2, d): will cause a  syntax error, because a parameter without a default value cannot follow  parameters with default values.

Option (iv) If a parameter does not have a default  value, it must be the first parameter in the list of parameters.

# Option (i) with fixed parameter order def func(b, a = 1):    pass # Option (ii) with fixed parameter order def func(b, a = 1, c = 2):    pass

Could people breathe the air on Mars?

Visit other story