fork download
  1. import math
  2. class DataPoint:
  3. def __init__(self, Datum, Error, Operator):
  4. self.Datum = Datum
  5. self.Error = Error
  6. self.Operator = Operator
  7. def ReturnDatum(self):
  8. return self.Datum
  9. def ReturnError(self):
  10. return self.Error
  11. def ReturnOperator(self):
  12. return self.Operator
  13. def __add__(self, other):
  14. return DataPoint(self.Datum + other.Datum, math.sqrt(self.Error * self.Error + other.Error * other.Error), 'NULL')
  15.  
  16. Obj1 = DataPoint(3.4, 0.12, '+')
  17. Obj2 = DataPoint(123.1, 3.56, '/')
  18. Obj3 = Obj1 + Obj2
Success #stdin #stdout 0.08s 8664KB
stdin
Standard input is empty
stdout
Standard output is empty