Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
920 B
1
Indexable
Never
class phanso():
    def __init__(self):
        self.tuso = float(input("Nhap tu so: "))
        self.mauso = float(input("Nhap mau so: "))
        while (self.mauso == 0):
            if (self.mauso == 0):
                print("Gia tri mau so phai khac 0")
                self.mauso = float(input("Nhap lai mau so: "))

    def sosanh(self, b):
        self.tuso = self.tuso * (b.mauso/self.mauso)
        if (self.tuso > b.tuso):
            print("Phan so thu nhat lon hon")
        elif (self.tuso < b.tuso):
            print("Phan so thu 2 lon hon")
        else:
            print("Hai phan so bang nhau")

    def addelement(self):
        arr = []
        n = int(input("Nhap so phan tu cua mang: "))
        for i in range(n):
            a = phanso()
            arr.append(a)
        for i in arr:
            print(i)


a = phanso()
b = phanso()
a.sosanh(b)
a.addelement()