Task: Implement a Calculator class in the /app/ directory that performs basic arithmetic operations.
Requirements:
The Calculator class must have the following methods:
add(a: float, b: float) -> float: Returns the sum of a and b.
subtract(a: float, b: float) -> float: Returns the difference when b is subtracted from a.
multiply(a: float, b: float) -> float: Returns the product of a and b.
divide(a: float, b: float) -> float: Returns the quotient when a is divided by b. If b is zero, raise a ValueError with the message "Cannot divide by zero."
The Calculator class should maintain an internal state that stores the last result from any operation. This state can be accessed via a property called last_result, which is a float.
The last_result property should update automatically after each operation (add, subtract, multiply, divide) is called.
Proper error handling should be in place to ensure that all operations handle invalid input types gracefully by either raising a TypeError or returning a meaningful result.
By implementing this class and its functionality, all test cases associated with the Calculator class will pass. Ensure that the implementation is efficient and follows best practices for coding standards.