fork download
  1. class Screen(object):
  2. @property
  3. def width(self):
  4. return self._width
  5. @width.setter
  6. def width(self, value):
  7. self._width = value
  8.  
  9. @property
  10. def height(self):
  11. return self._height
  12. @height.setter
  13. def height(self, value):
  14. self._height = value
  15.  
  16. @property
  17. def resolution(self):
  18. return self._width * self._height
  19.  
  20. # 测试:
  21. s = Screen()
  22. s.width = 1024
  23. s.height = 768
  24. print('resolution =', s.resolution)
  25. if s.resolution == 786432:
  26. print('测试通过!')
  27. else:
  28. print('测试失败!')
  29.  
  30. # your code goes here
Success #stdin #stdout 0.07s 14064KB
stdin
Standard input is empty
stdout
resolution = 786432
测试通过!