Lesson 21 of 34

Functions: आपके अपने commands

8 min 25 XP

एक ही कोड बार-बार लिख रहे हैं? उसका function बना लीजिए। def से शुरू करें, फिर नाम, ( ) और :, और अंदर का कोड indent करें।

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) उसे चलाता नहीं है। उसे बुलाना पड़ता है: greet(...)

Challenge

+25 XP

एक function greet(name) लिखें जो "Vanakkam, <name>!" print करे। फिर greet("Arun") और greet("Priya") बुलाएँ।

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