Advertisements
Advertisements
प्रश्न
Observe the following program carefully, and identify the error:
def findValue( vall = 1.1, val2, val3):
final = (val2 + val3)/ vall
print(final)
findvalue() #function callटीपा लिहा
Advertisements
उत्तर
There are three errors in the given program:
- The ‘function call’ in line 4 is calling an invalid function. 'findValue()' is different from 'findvalue()' as Python is case sensitive.
- 'findValue()' function needs the value of at least 2 arguments val2 and val3 to work, which is not provided in the function call.
- As 'vall' is already initialized as 'vall = 1.0', it is called 'Default parameter' and it should be always after the mandatory parameters in the function definition. i.e. def findValue(val2, val3, vall = 1.0) is the correct statement.
shaalaa.com
Arguments and Parameters
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
