Lesson 21 of 34
Functions: உங்கள் சொந்த கட்டளைகள்Functions: Your Own Commands
8 min 25 XP
ஒரே code-ஐ பல இடங்களில் திரும்பத் திரும்ப எழுதுகிறீர்களா? அதை ஒரு function-ஆக்குங்கள். def என்று தொடங்கி, பெயர், ( ), : எழுதி, உள்ளே indent செய்து code எழுதுங்கள்.
Writing the same code again and again? Make it a function. Start with def, then a name, ( ) and :, and indent the code inside.
Example: edit me and press Run
Press Run to see the result here.( ) உள்ளே parameters கொடுக்கலாம். function-ஐ அழைக்கும் போது கொடுக்கும் மதிப்புகள் (arguments) அவற்றில் வந்து சேரும்.
Put parameters inside ( ). The values you pass when calling the function (arguments) arrive in them.
Example: edit me and press Run
Press Run to see the result here.function-ஐ வரையறுப்பது (def) மட்டும் அதை இயக்காது. அதை அழைக்க (call) வேண்டும்: greet(...)
Defining a function (def) doesn't run it. You have to call it: greet(...)