diff --git a/python/src/main.py b/python/src/main.py index e37a77c..1adbfef 100644 --- a/python/src/main.py +++ b/python/src/main.py @@ -1,7 +1,11 @@ -def summ(a: int, b: int) -> int: - return a + b +import primer1 +import structure +print(primer1.taskone(0.26, 0.66, 0.08)) +print(primer1.tasktwo(0.1, 0.35, 0.4, 0.55,0.6)) -if __name__ == "__main__": - print("Hello world") - print(summ(3, 4)) + + +chel = structure.Character("Владик Пармезан",7,8,7,8) +chel.print_overall_info() +chel.event() diff --git a/python/src/primer1.py b/python/src/primer1.py new file mode 100644 index 0000000..76f2dbe --- /dev/null +++ b/python/src/primer1.py @@ -0,0 +1,19 @@ +import math + +def calculate(x): + return (((math.asin(x))**2 + (math.acos(x))**4)**3) + +def taskone(x_s,x_e,x_k): + results=[] + while x_s < x_e: + results.append(calculate(x_s)) + x_s+=x_k + return results + +def tasktwo(x1,x2,x3,x4,x5): + results2=[] + for a in x1,x2,x3,x4,x5: + results2.append(calculate(a)) + return results2 + + diff --git a/python/src/structure.py b/python/src/structure.py new file mode 100644 index 0000000..88d0cae --- /dev/null +++ b/python/src/structure.py @@ -0,0 +1,83 @@ +from random import randint + +class Character: + def __init__(self, name, intellect, psyche, physique, motorics): + self.__name = name + self.__intellect = intellect + self.__psyche = psyche + self.__physique = physique + self.__motorics = motorics + + @property + def name(self): + return self.__name + + + @property + def intellect(self): + return self.__intellect + + @intellect.setter + def intellect(self, intellect): + if 0 < intellect < 11: + self.__intellect = intellect + else: + print("Количество очков интеллекта может быть только от 1 до 10.") + + + @property + def psyche(self): + return self.psyche + + @psyche.setter + def psyche(self, psyche): + if 0 < psyche < 11: + self.__psyche = psyche + else: + print("Количество очков психики может быть только от 1 до 10.") + + + @property + def physique(self): + return self.physique + + @physique.setter + def physique(self, physique): + if 0 < physique < 11: + self.__physique = physique + else: + print("Количество очков физиологии может быть только от 1 до 10.") + + + @property + def motorics(self): + return self.motorics + + @motorics.setter + def motorics(self, motorics): + if 0 < motorics < 11: + self.__motorics = motorics + else: + print("Количество очков моторики может быть только от 1 до 10.") + + + def print_overall_info(self): + if 0 < self.__intellect < 11 and 0 < self.__psyche < 11 and 0 < self.__physique < 11 and 0 < self.__motorics < 11: + print(f"Имя: {self.__name}\nИнтеллект: {self.__intellect}\nПсихика: {self.__psyche}\nФизиология: {self.__physique}\nМоторика: {self.__motorics}\n") + else: + print("Параметры персонажа были заданы неверно: характеристики могут принимать значения только от 1 до 10.") + + def event(self): + if 0 < self.__intellect < 11 and 0 < self.__psyche < 11 and 0 < self.__physique < 11 and 0 < self.__motorics < 11: + a = randint(4, 53) + b = randint(2, 13) + all = self.__intellect + self.__psyche + self.__physique + self.__motorics + if (all + b)>= a: + print(f"Событие пройдено успешно.\nБыло необходимо очков:{a}\nСумма характеристик составила:{all}\nКубики выбросили число:{b}\nСумма ваших очков:{all + b}") + else: + print(f"Событие провалено.\nБыло необходимо очков:{a}\nСумма характеристик составила:{all}\nКубики выбросили число:{b}") + else: + print("Параметры персонажа были заданы неверно: характеристики могут принимать значения только от 1 до 10.") + + +