Dimitar23308

Untitled

Dec 16th, 2025
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. # class Temperature:
  2. # ABSOLUTE_ZERO = -273.15
  3.  
  4. # def __init__(self, celsius):
  5. # self.celsius = celsius
  6.  
  7. # @property
  8. # def celsius(self):
  9. # return self._celsius
  10.  
  11. # @celsius.setter
  12. # def celsius(self, value):
  13. # if value < self.ABSOLUTE_ZERO:
  14. # raise ValueError("Температурата не може да е под абсолютната нула")
  15. # self._celsius = value
  16.  
  17. # def increase(self, value):
  18. # if value <= 0:
  19. # raise ValueError("Стойността за увеличаване трябва да е положителна")
  20. # self.celsius = self.celsius + value
  21.  
  22. # @staticmethod
  23. # def celsius_to_fahrenheit(c):
  24. # return c * 9 / 5 + 32
  25.  
  26. # @staticmethod
  27. # def fahrenheit_to_celsius(f):
  28. # return (f - 32) * 5 / 9
  29.  
  30. # @staticmethod
  31. # def is_freezing(c):
  32. # return c <= 0
  33.  
  34. # temp = Temperature(25)
  35. # print("Текуща температура:", temp.celsius)
  36.  
  37. # temp.increase(5)
  38. # print("След увеличение:", temp.celsius)
  39.  
  40. # print("Във Фаренхайт:", Temperature.celsius_to_fahrenheit(temp.celsius))
  41. # print("От Фаренхайт към Целзий:", Temperature.fahrenheit_to_celsius(32))
  42. # print("Замръзване ли е:", Temperature.is_freezing(temp.celsius))
  43. ___________________________________________________________________________________
  44.  
  45. # class User:
  46. # def __init__(self, username):
  47. # self.username = username
  48.  
  49. # @property
  50. # def username(self):
  51. # return self._username
  52.  
  53. # @username.setter
  54. # def username(self, value):
  55. # if len(value) >= 5:
  56. # self._username = value
  57. # else:
  58. # raise ValueError("poveche ot 5 simvola")
  59.  
  60. # @staticmethod
  61. # def username_length(username):
  62. # return len(username)
  63.  
  64. ____________________________________________________________________________________
  65.  
  66. # class Rectangle:
  67. # def __init__(self, width, height):
  68. # self.width = width
  69. # self.height = height
  70.  
  71. # def get_width(self):
  72. # return self._width
  73.  
  74. # def set_width(self, width):
  75. # if width > 0:
  76. # self._width = width
  77. # else:
  78. # raise ValueError(">0!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
  79.  
  80. # def get_height(self):
  81. # return self._height
  82.  
  83. # def set_height(self, height):
  84. # if height > 0:
  85. # self._height = height
  86. # else:
  87. # raise ValueError(" > 0!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
  88.  
  89. # width = property(get_width, set_width)
  90. # height = property(get_height, set_height)
  91.  
  92. # @staticmethod
  93. # def is_square(width, height):
  94. # return width == height
  95. _____________________________________________________________________________________
  96. class Student:
  97. def __init__(self, grade):
  98. self.grade = grade
  99.  
  100. def get_grade(self):
  101. return self._grade
  102.  
  103. def set_grade(self, grade):
  104. if 2.00 <= grade <= 6.00:
  105. self._grade = grade
  106. else:
  107. raise ValueError("Оценката трябва да е между 2.00 и 6.00")
  108.  
  109. grade = property(get_grade, set_grade)
  110.  
  111. @staticmethod
  112. def has_passed(grade):
  113. return grade >= 3.00
  114. student = Student(4.50)
  115. print("Текуща оценка:", student.grade)
  116. ___________________________________________________________________________________
Advertisement
Add Comment
Please, Sign In to add comment