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 call करताना दिलेल्या values (arguments) त्यात येतात.

Example: edit me and press Run

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

Function define (def) केल्याने ते चालत नाही. ते call करावे लागते: greet(...)

Challenge

+25 XP

"Vanakkam, <name>!" print करणारे function greet(name) लिहा. मग greet("Arun") आणि greet("Priya") call करा.

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