Python Programming LangaugePython Programming Langauge


In the above example the function displayFruits is called without the parameters then it has displayed the elements of the list fruit which is declared in the function. Second time the function displayFruits is called, then it is called with the parameter fruits which is declared and initialized in main. So now it displays the values of the elements of the passed parameter.




In the above example while declaring and defining of the function printStudentDetail parameters 'age' and 'stream' is initialized with the value 21 and MSc-Cs respectively. So while calling the function, only one value for parameter 'name' is needed to be sent. In such case, it takes the value for 'name' and for other two parameters age and stream it takes the value which is already initialized in the function header. So in the example shown above, value for the parameter 'name' is passed as Vinay and it takes the value for 'age' as 21 and value for 'stream' as MSc-Cs. But when the second time the function printStudentDetail is called, then it is called with three values so all the three variable's value is replaced i.e. 'name' as Mahesh, 'age' as 20 and 'stream' as CS. The example continues with other parameters. Thus the initialed dafault values are overidden.


Functions...<< Previous

Next >> Modules

By: Vishwanath Pai M

Reference: IOT by Arshdeep Bahga, Vijay Madisetti

Our aim is to provide information to the knowledge seekers. 


comments powered by Disqus










Footer1