class Calculator:
    def calculate(self):
        res = 0

        while True:
            print("Welcome to the calculator !!!")
            print("To use the precedent result,use 'res' instead of a number")

            nbr1 = input("Enter the first number: ")
            nbr2 = input("Enter the second number: ")
            if nbr1 == "res":
                nbr1 = res
            else:
                nbr1 = float(nbr1)

            if nbr2 == "res":
                nbr2 = res
            else:
                nbr2 = float(nbr2)

            operator = input("Enter the operator: ")

            if operator == "+":
                res = nbr1 + nbr2
            elif operator == "-":
                res = nbr1 - nbr2
            elif operator == "*":
                res = nbr1 * nbr2
            elif operator == "/":
                if nbr2 == 0:
                    print("You cannot divide by zero")
                else :
                    res = nbr1 / nbr2
            else :
                res = "Invalid operator"

            print("The res is", res)

Calculator().calculate()

#print("Addition : ",add)
#print("Substraction : ",sub)
#print("Multiplication : ",multiply)
#print("Division : ",divide)