Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # class Temperature:
- # ABSOLUTE_ZERO = -273.15
- # def __init__(self, celsius):
- # self.celsius = celsius
- # @property
- # def celsius(self):
- # return self._celsius
- # @celsius.setter
- # def celsius(self, value):
- # if value < self.ABSOLUTE_ZERO:
- # raise ValueError("Температурата не може да е под абсолютната нула")
- # self._celsius = value
- # def increase(self, value):
- # if value <= 0:
- # raise ValueError("Стойността за увеличаване трябва да е положителна")
- # self.celsius = self.celsius + value
- # @staticmethod
- # def celsius_to_fahrenheit(c):
- # return c * 9 / 5 + 32
- # @staticmethod
- # def fahrenheit_to_celsius(f):
- # return (f - 32) * 5 / 9
- # @staticmethod
- # def is_freezing(c):
- # return c <= 0
- # temp = Temperature(25)
- # print("Текуща температура:", temp.celsius)
- # temp.increase(5)
- # print("След увеличение:", temp.celsius)
- # print("Във Фаренхайт:", Temperature.celsius_to_fahrenheit(temp.celsius))
- # print("От Фаренхайт към Целзий:", Temperature.fahrenheit_to_celsius(32))
- # print("Замръзване ли е:", Temperature.is_freezing(temp.celsius))
- ___________________________________________________________________________________
- # class User:
- # def __init__(self, username):
- # self.username = username
- # @property
- # def username(self):
- # return self._username
- # @username.setter
- # def username(self, value):
- # if len(value) >= 5:
- # self._username = value
- # else:
- # raise ValueError("poveche ot 5 simvola")
- # @staticmethod
- # def username_length(username):
- # return len(username)
- ____________________________________________________________________________________
- # class Rectangle:
- # def __init__(self, width, height):
- # self.width = width
- # self.height = height
- # def get_width(self):
- # return self._width
- # def set_width(self, width):
- # if width > 0:
- # self._width = width
- # else:
- # raise ValueError(">0!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
- # def get_height(self):
- # return self._height
- # def set_height(self, height):
- # if height > 0:
- # self._height = height
- # else:
- # raise ValueError(" > 0!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
- # width = property(get_width, set_width)
- # height = property(get_height, set_height)
- # @staticmethod
- # def is_square(width, height):
- # return width == height
- _____________________________________________________________________________________
- class Student:
- def __init__(self, grade):
- self.grade = grade
- def get_grade(self):
- return self._grade
- def set_grade(self, grade):
- if 2.00 <= grade <= 6.00:
- self._grade = grade
- else:
- raise ValueError("Оценката трябва да е между 2.00 и 6.00")
- grade = property(get_grade, set_grade)
- @staticmethod
- def has_passed(grade):
- return grade >= 3.00
- student = Student(4.50)
- print("Текуща оценка:", student.grade)
- ___________________________________________________________________________________
Advertisement
Add Comment
Please, Sign In to add comment