Lesson 23 of 34
Default & Keyword ArgumentsDefault & Keyword Arguments
8 min 30 XP
ஒரு parameter-க்கு இயல்பு மதிப்பு (default) கொடுக்கலாம். அழைக்கும் போது அதைக் கொடுக்காவிட்டால் default பயன்படுத்தப்படும்.
Give a parameter a default value. If the caller leaves it out, the default is used.
Example: edit me and press Run
Press Run to see the result here.Keyword arguments: பெயரைச் சொல்லி மதிப்பைக் கொடுத்தால் வரிசை முக்கியமில்லை. இதனால் code படிக்கவும் எளிதாகும்.
Keyword arguments: pass values by name and the order no longer matters. It also makes code easier to read.
Example: edit me and press Run
Press Run to see the result here.default உள்ள parameters, default இல்லாதவற்றுக்குப் பின்னால் தான் வர வேண்டும்: def f(a, b=2) சரி, def f(a=1, b) தவறு.
Parameters with defaults must come after those without: def f(a, b=2) is fine, def f(a=1, b) is an error.