Hướng dẫn overlaps code in python - mã chồng chéo trong python

Quá tải toán tử có nghĩa là đưa ra ý nghĩa mở rộng vượt ra ngoài ý nghĩa hoạt động được xác định trước của chúng. Ví dụ, toán tử + được sử dụng để thêm hai số nguyên cũng như tham gia hai chuỗi và hợp nhất hai danh sách. Nó có thể đạt được bởi vì toán tử ‘++bị quá tải bởi lớp Int và lớp str. Bạn có thể nhận thấy rằng cùng một toán tử hoặc chức năng tích hợp cho thấy hành vi khác nhau cho các đối tượng của các lớp khác nhau, điều này được gọi là quá tải toán tử. & NBSP; means giving extended meaning beyond their predefined operational meaning. For example operator + is used to add two integers as well as join two strings and merge two lists. It is achievable because ‘+’ operator is overloaded by int class and str class. You might have noticed that the same built-in operator or function shows different behavior for objects of different classes, this is called Operator Overloading.  means giving extended meaning beyond their predefined operational meaning. For example operator + is used to add two integers as well as join two strings and merge two lists. It is achievable because ‘+’ operator is overloaded by int class and str class. You might have noticed that the same built-in operator or function shows different behavior for objects of different classes, this is called Operator Overloading. 

Show

    Thí dụ

    Python3

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    90
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    91
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    92
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    93

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    90

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    3
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    92
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    5
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    90

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    9
    ob2 is greater than ob1
    0
    ob2 is greater than ob1
    1
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    90

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    3
    ob2 is greater than ob1
    0
    ob2 is greater than ob1
    1
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0

    Đầu ra

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    2

    Làm thế nào để làm quá tải các toán tử trong Python? & NBSP;  

    Hãy xem xét rằng chúng ta có hai đối tượng là biểu diễn vật lý của một lớp (loại dữ liệu do người dùng xác định) và chúng ta phải thêm hai đối tượng với toán tử '+' nhị phân, nó đã gây ra lỗi, vì trình biên dịch không biết cách thêm hai đối tượng . Vì vậy, chúng tôi xác định một phương thức cho toán tử và quá trình đó được gọi là quá tải toán tử. Chúng ta có thể quá tải tất cả các toán tử hiện có nhưng chúng ta có thể tạo ra một nhà khai thác mới. Để thực hiện quá tải toán tử, Python cung cấp một số chức năng đặc biệt hoặc chức năng ma thuật được tự động gọi khi nó được liên kết với toán tử cụ thể đó. Ví dụ: khi chúng ta sử dụng toán tử +, phương thức ma thuật __add__ sẽ tự động được gọi trong đó hoạt động cho toán tử + được xác định.

    Quá tải toán tử nhị phân + trong python: & nbsp;  

    Khi chúng tôi sử dụng toán tử trên các loại dữ liệu do người dùng xác định thì tự động chức năng đặc biệt hoặc hàm ma thuật được liên kết với toán tử đó sẽ được gọi. Thay đổi hành vi của toán tử cũng đơn giản như thay đổi hành vi của phương thức hoặc hàm. Bạn xác định các phương thức trong lớp và các nhà khai thác của bạn làm việc theo hành vi đó được xác định trong các phương thức. Khi chúng ta sử dụng toán tử +, phương thức ma thuật __add__ sẽ tự động được gọi trong đó hoạt động cho toán tử + được xác định. Do đó, thay đổi mã phương thức ma thuật này, chúng ta có thể cung cấp thêm ý nghĩa cho toán tử +. & NBSP;

    Làm thế nào để người vận hành quá tải thực sự hoạt động?

    Bất cứ khi nào bạn thay đổi hành vi của toán tử hiện có thông qua quá tải toán tử, bạn phải xác định lại chức năng đặc biệt được gọi tự động khi toán tử được sử dụng với các đối tượng. & NBSP;existing operator through operator overloading, you have to redefine the special function that is invoked automatically when the operator is used with the objects. existing operator through operator overloading, you have to redefine the special function that is invoked automatically when the operator is used with the objects. 

    Ví dụ: & nbsp;

    Mã 1: & nbsp; & nbsp;  

    Python3

    ob2 is greater than ob1
    9
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    40
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    41
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    42
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    43
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    45
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    46
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    48
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    40
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    41
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    42
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    43
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    95
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    46
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    47
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    48
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    92
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    891

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    892

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    91____10

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    897

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    93
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    902

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    3
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    907

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    5
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    913
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    92
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    915

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    9177____8
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    919

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    921

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    923

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    925

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    927

    Đầu ra

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor

    Làm thế nào để làm quá tải các toán tử trong Python? & NBSP; __add__( )”  and when the objects ob1 and ob2are coded as “ob1 + ob2“, the special function is automatically called as ob1.__add__(ob2) which simply means that ob1 calls the __add__( ) function with ob2 as an Argument and It actually means A .__add__(ob1, ob2). Hence, when the Binary operator is overloaded, the object before the operator calls the respective function with object after operator as parameter.

    Hãy xem xét rằng chúng ta có hai đối tượng là biểu diễn vật lý của một lớp (loại dữ liệu do người dùng xác định) và chúng ta phải thêm hai đối tượng với toán tử '+' nhị phân, nó đã gây ra lỗi, vì trình biên dịch không biết cách thêm hai đối tượng . Vì vậy, chúng tôi xác định một phương thức cho toán tử và quá trình đó được gọi là quá tải toán tử. Chúng ta có thể quá tải tất cả các toán tử hiện có nhưng chúng ta có thể tạo ra một nhà khai thác mới. Để thực hiện quá tải toán tử, Python cung cấp một số chức năng đặc biệt hoặc chức năng ma thuật được tự động gọi khi nó được liên kết với toán tử cụ thể đó. Ví dụ: khi chúng ta sử dụng toán tử +, phương thức ma thuật __add__ sẽ tự động được gọi trong đó hoạt động cho toán tử + được xác định.

    Python3

    Quá tải toán tử nhị phân + trong python: & nbsp;

    Khi chúng tôi sử dụng toán tử trên các loại dữ liệu do người dùng xác định thì tự động chức năng đặc biệt hoặc hàm ma thuật được liên kết với toán tử đó sẽ được gọi. Thay đổi hành vi của toán tử cũng đơn giản như thay đổi hành vi của phương thức hoặc hàm. Bạn xác định các phương thức trong lớp và các nhà khai thác của bạn làm việc theo hành vi đó được xác định trong các phương thức. Khi chúng ta sử dụng toán tử +, phương thức ma thuật __add__ sẽ tự động được gọi trong đó hoạt động cho toán tử + được xác định. Do đó, thay đổi mã phương thức ma thuật này, chúng ta có thể cung cấp thêm ý nghĩa cho toán tử +. & NBSP;

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    46
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    48
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    40
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    41
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    42
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    43
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    45
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    46
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    47
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    48
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    92
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    891

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    892

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    91____10

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    897

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    93
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    902

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    3
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    907

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    5
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    43

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    913
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    92
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    915  
      

    Python3

    ob2 is greater than ob1
    9
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    40
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    41
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    42
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    4 3
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    45
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    46
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    48
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    40
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    41
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    42
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    43
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    45
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    46
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    62
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    90
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    65
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    46
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    47
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    48
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    92
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    891
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    46
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    70
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    930

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    892

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    91____10

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    897

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    93
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    902

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    3
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0

    Output:

    ob2 is greater than ob1

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    5
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0
     

    Python3

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    913
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    92
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    915  

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    892

    ob2 is greater than ob1
    9
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    40
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    41
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    42
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    4 3
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    45
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    46
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    48
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    40
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    41
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    42
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    43
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    45
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    46
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    62
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    90
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    65
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    46
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    47
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    48
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    92
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    891
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    46
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    70
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    930

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    897

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    3
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    62
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    86
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    41
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    90
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    90
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    70
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    930
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    41
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    90
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    97
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89

    ob2 is greater than ob1
    63

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    902

    Quá tải bình đẳng và ít hơn các toán tử: & nbsp; 

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    907

    Quá tải bình đẳng và ít hơn các toán tử: & nbsp; 

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    913

    ob2 is greater than ob1
    9
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    40
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    41
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    42
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    43
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    45
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    46
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    48
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    40
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    41
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    42
    ob2 is greater than ob1
    13
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    10
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    46
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    62
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    90
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    ob2 is greater than ob1
    20
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    66
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    47
    ob2 is greater than ob1
    23
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    46
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    70
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    930
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    66
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    47
    ob2 is greater than ob1
    29
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    41
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    42
    ob2 is greater than ob1
    32
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    10
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    46
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    62
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    90
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    44
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    48
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    66
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    47
    ob2 is greater than ob1
    45
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    546
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    70
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    930
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    66
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    47
    ob2 is greater than ob1
    51

    Output:

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    4

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    93__

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    9____10

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    ob2 is greater than ob1
    1
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    915
    Phương pháp ma thuật Python hoặc các chức năng đặc biệt cho quá tải người vận hànhNhà khai thác nhị phân:
    Nhà điều hànhPhương pháp ma thuật
    +__add __ (bản thân, người khác)
    -__Sub __ (bản thân, người khác)
    *__mul __ (bản thân, người khác)
    /__truediv __ (bản thân, người khác)
    //__floordiv __ (bản thân, người khác)
    Phần trăm__mod __ (bản thân, người khác)
    **__pow __ (bản thân, người khác)
    >>__rshift __ (bản thân, người khác)
    |__lshift __ (bản thân, người khác)
    Không có giá trị__and __ (bản thân, người khác)

    |

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    ob2 is greater than ob1
    1
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    915
    **__pow __ (bản thân, người khác)
    >>__rshift __ (bản thân, người khác)
    **__pow __ (bản thân, người khác)
    >>__rshift __ (bản thân, người khác)
    |__lshift __ (bản thân, người khác)
    Không có giá trị __and __ (bản thân, người khác)

    |

    __or __ (bản thân, người khác)^
    __xor __ (bản thân, người khác) Toán tử so sánh:
    __lt __ (bản thân, người khác) >
    __gt __ (bản thân, người khác) __le __ (bản thân, người khác)
    > = __ge __ (bản thân, người khác)
    == __eq __ (bản thân, người khác)
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    915
    Phương pháp ma thuật Python hoặc các chức năng đặc biệt cho quá tải người vận hành
    Nhà khai thác nhị phân: Nhà điều hành
    Phương pháp ma thuật +
    ** __pow __ (bản thân, người khác)
    >> __rshift __ (bản thân, người khác)
    | __lshift __ (bản thân, người khác)
    Không có giá trị __and __ (bản thân, người khác)

    |

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    ob2 is greater than ob1
    1
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    0
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    915
    Nhà điều hành Phương pháp ma thuật
    Phương pháp ma thuật Python hoặc các chức năng đặc biệt cho quá tải người vận hành Nhà khai thác nhị phân:
    Nhà điều hành Phương pháp ma thuật

    +It is not possible to change the number of operands of an operator. For example: If we can not overload a unary operator as a binary operator. The following code will throw a syntax error.

    Python3

    __add __ (bản thân, người khác)

    __mul __ (bản thân, người khác)

    /

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    892

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    49
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    93__

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    89

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    405

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    897

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    869
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    9____109
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    894
    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    9____10

    3
    GeeksFor
    3
    GeeksFor
    3
    GeeksFor
    4