सबको एक साथ जोड़ते हुए

Python में Functions का परिचय

Hugo Bowne-Anderson

Instructor

अगले अभ्यास:

  • Generalized functions:

    • किसी भी कॉलम के लिए occurrences गिनें

    • मनचाहे संख्या के कॉलम्स के लिए occurrences गिनें

Python में Functions का परिचय

एक default argument जोड़ें

def power(number, pow=1):
    """Raise number to the power of pow."""
    new_value = number ** pow
    return new_value
power(9, 2)
81
power(9)
9
Python में Functions का परिचय

Flexible arguments: *args (1)

def add_all(*args):
    """Sum all values in *args together."""

    # Initialize sum
    sum_all = 0

    # Accumulate the sum
    for num in args:
        sum_all = sum_all + num

    return sum_all
Python में Functions का परिचय

अभ्यास करते हैं!

Python में Functions का परिचय

Preparing Video For Download...