Tổng hợp lại

Giới thiệu về Functions trong Python

Hugo Bowne-Anderson

Instructor

Quý vị đã học:

  • Cách viết hàm

    • Nhận nhiều tham số

    • Trả về nhiều giá trị

  • Tiếp theo: Hàm phân tích dữ liệu Twitter

Giới thiệu về Functions trong Python

Thành phần cơ bản của một hàm

  • Phần đầu hàm
def raise_both(value1, value2):
  • Thân hàm
    """Raise value1 to the power of value2
    and vice versa."""

    new_value1 = value1 ** value2          
    new_value2 = value2 ** value1

    new_tuple = (new_value1, new_value2)

    return new_tuple
Giới thiệu về Functions trong Python

Hãy luyện tập!

Giới thiệu về Functions trong Python

Preparing Video For Download...