Lesson 21 of 34

Functions: உங்கள் சொந்த கட்டளைகள்

8 min 25 XP

ஒரே code-ஐ பல இடங்களில் திரும்பத் திரும்ப எழுதுகிறீர்களா? அதை ஒரு function-ஆக்குங்கள். def என்று தொடங்கி, பெயர், ( ), : எழுதி, உள்ளே indent செய்து code எழுதுங்கள்.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

( ) உள்ளே parameters கொடுக்கலாம். function-ஐ அழைக்கும் போது கொடுக்கும் மதிப்புகள் (arguments) அவற்றில் வந்து சேரும்.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

function-ஐ வரையறுப்பது (def) மட்டும் அதை இயக்காது. அதை அழைக்க (call) வேண்டும்: greet(...)

Challenge

+25 XP

greet(name) என்ற function எழுதுங்கள். அது "Vanakkam, <name>!" என்று print செய்ய வேண்டும். பிறகு greet("Arun") மற்றும் greet("Priya") என அழையுங்கள்.

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.