class Point: def __init__(self, x = 0, y = 0): self.x = x self.y = y def __sub__(self, other): x = self.x + other.x y = self.y + other.y return Point(x, y) p1 = Point(3, 4) p2 = Point(1, 2) result = p1 – p2 print(result.x, result.y) Kết quả của chương trình dưới đây là:

class Point:

def __init__(self, x = 0, y = 0):

self.x = x

self.y = y

def __sub__(self, other):

x = self.x + other.x

y = self.y + other.y

return Point(x, y)

p1 = Point(3, 4)

p2 = Point(1, 2)

result = p1 – p2

print(result.x, result.y)

Kết quả của chương trình dưới đây là:

A. 2 2

B. 4 6

C. 0 0

D. 1 1

Hướng dẫn

Chọn B là đáp án đúng

 

Thư viện tài liệu12 Tháng bảy, 2023 @ 2:30 chiều

Đánh giá chủ đề này
How to whitelist website on AdBlocker?

How to whitelist website on AdBlocker?

  1. 1 Click on the AdBlock Plus icon on the top right corner of your browser
  2. 2 Click on "Enabled on this site" from the AdBlock Plus option
  3. 3 Refresh the page and start browsing the site