# P7.1 Python मध्ये Function म्हणजे काय आणि का वापरायचं?

Source: https://ravindrabagale.com/mr/datascience/py07-python-functions-tutorial-def-return-arguments-and-lambda/p7-1-what-is-a-function-in-python-and-why-use-it.html
Language: mr (Marathi with English technical terms)

हे का शिकायचं?

तोच हिशोब दहा ठिकाणी लिहिला तर चूक दहा ठिकाणी होते. Function एकदा लिहा, अनेकदा वापरा.

हे काय आहे?

def name(inputs): ने function बनतं. आतला code function call केल्यावरच चालतो.

कसं करायचं?

Step 1. def आणि नाव लिहा.
Step 2. कंसात inputs लिहा.
Step 3. आतला code indent करा.
Step 4. name(...) ने call करा.

उदाहरण A: सगळ्यात छोटं function

```python
def greet():
    print("Hello, how can we help?")

greet()
greet()
```

Output:

```text
Hello, how can we help?
Hello, how can we help?
```

याचा अर्थ: Function call केल्यावरच आतला code चालला.

उदाहरण B: Input असलेलं function

```python
def greet(name):
    print(f"Hello {name}, how can we help?")

greet("Aisha")
greet("Marco")
```

Output:

```text
Hello Aisha, how can we help?
Hello Marco, how can we help?
```

याचा अर्थ: Input बदलला की तेच function वेगळं उत्तर देतं.

रवींद्र बागले यांची tip

Functions ला क्रियापदाची नावं द्या: `calculate_tax`, `clean_city`, `load_orders`. Function काहीतरी करतं.
