diff --git a/lesson_1/.idea/.gitignore b/lesson_1/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/lesson_1/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/lesson_1/.idea/inspectionProfiles/profiles_settings.xml b/lesson_1/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/lesson_1/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/lesson_1/.idea/lesson_1.iml b/lesson_1/.idea/lesson_1.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/lesson_1/.idea/lesson_1.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lesson_1/.idea/misc.xml b/lesson_1/.idea/misc.xml new file mode 100644 index 0000000..d1e22ec --- /dev/null +++ b/lesson_1/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/lesson_1/.idea/modules.xml b/lesson_1/.idea/modules.xml new file mode 100644 index 0000000..a4e1be5 --- /dev/null +++ b/lesson_1/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lesson_1/.idea/vcs.xml b/lesson_1/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/lesson_1/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lesson_1/1.py b/lesson_1/1.py new file mode 100644 index 0000000..101cd44 --- /dev/null +++ b/lesson_1/1.py @@ -0,0 +1,3 @@ +name=input("Your name:") +city=input("Were are you from?:") +print("Hi, ", name, " from ", city, "!", sep="") \ No newline at end of file diff --git a/lesson_1/2.py b/lesson_1/2.py new file mode 100644 index 0000000..d1b81c6 --- /dev/null +++ b/lesson_1/2.py @@ -0,0 +1,17 @@ +a = int(input("Введите время в секундах:")) +h = (a // 3600) +m = (a // 60) % 60 +s = a % 60 +if h < 10: + h = '0' + str(h) +else: + h = str(h) +if m < 10: + m = '0' + str(m) +else: + m = str(m) +if s < 10: + s = '0' + str(s) +else: + s = str(s) +print(h + ':' + m + ':' + s) diff --git a/lesson_1/3.py b/lesson_1/3.py new file mode 100644 index 0000000..6741184 --- /dev/null +++ b/lesson_1/3.py @@ -0,0 +1,5 @@ +a = input("Введите число:") +m = (a + a) +s = (a + a + a) +t = int(a) + int(m) + int(s) +print(str(a)+ "+" +str(m)+ "+" +str(s)+ "=" +str(t)) \ No newline at end of file diff --git a/lesson_1/4.py b/lesson_1/4.py new file mode 100644 index 0000000..0594791 --- /dev/null +++ b/lesson_1/4.py @@ -0,0 +1,8 @@ +a = int(input("Введите число:")) +m = a % 10 +a = a // 10 +while a > 0: + if a % 10 > m: + m = a % 10 + a = a // 10 +print("Максимальная цифра в числе:", m, ) diff --git a/lesson_1/5.py b/lesson_1/5.py new file mode 100644 index 0000000..a7cb7e9 --- /dev/null +++ b/lesson_1/5.py @@ -0,0 +1,10 @@ +a = int(input("Введите значение выручки Вашей фирмы:")) +b = int(input("Введите значение издержек Вашей фирмы:")) +if a > b: + c = a / b * 100 + print("Ваша фирма работает с положитьельным финансовым результатом! Показатель рентабельности:", round(c,2), "%") + d = int(input("Введите колличество сотрудников Вашей фирмы:")) + e = (a - b) / d + print("Прибыль в расчете на одного сотрудника фирмы составляет", round(e,2), ) +if a <= b: + print("Ваша фирма убыточна.") diff --git a/lesson_1/6.py b/lesson_1/6.py new file mode 100644 index 0000000..4664f13 --- /dev/null +++ b/lesson_1/6.py @@ -0,0 +1,8 @@ +a = int(input("Сколько киллометров Вы пробежали в 1 день?")) +b = int(input("Сколько киллометров Вы хотели бы пробегать?")) +day = 1 +while b > a: + a *= 1.1 + day += 1 +print("Вы пробегите" , b, "км. через" , day, "дней!") + diff --git a/lesson_2/.idea/.gitignore b/lesson_2/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/lesson_2/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/lesson_2/.idea/inspectionProfiles/profiles_settings.xml b/lesson_2/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/lesson_2/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/lesson_2/.idea/lesson_2.iml b/lesson_2/.idea/lesson_2.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/lesson_2/.idea/lesson_2.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lesson_2/.idea/misc.xml b/lesson_2/.idea/misc.xml new file mode 100644 index 0000000..d1e22ec --- /dev/null +++ b/lesson_2/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/lesson_2/.idea/modules.xml b/lesson_2/.idea/modules.xml new file mode 100644 index 0000000..fc71e6f --- /dev/null +++ b/lesson_2/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lesson_2/.idea/vcs.xml b/lesson_2/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/lesson_2/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lesson_2/1.py b/lesson_2/1.py new file mode 100644 index 0000000..a844a5b --- /dev/null +++ b/lesson_2/1.py @@ -0,0 +1,4 @@ +list = [2, "text", 45.3, False] +print(list) +for el in list: + print(el, type(el)) \ No newline at end of file diff --git a/lesson_2/2.py b/lesson_2/2.py new file mode 100644 index 0000000..106822f --- /dev/null +++ b/lesson_2/2.py @@ -0,0 +1,9 @@ +lis = [] +n = int(input('Введите колличество элементов в списке:')) +print("Введите элементы списка:") +for i in range(0, n): + ele = input() + lis.append(ele) +for i in range(1, len(lis), 2): + lis[i - 1], lis[i] = lis[i], lis[i - 1] + print(lis) \ No newline at end of file diff --git a/lesson_2/3,1.py b/lesson_2/3,1.py new file mode 100644 index 0000000..3cbe7f5 --- /dev/null +++ b/lesson_2/3,1.py @@ -0,0 +1,5 @@ +a = int(input("Введите месяц используя цифру от 1 до 12:")) +b = a - 1 +list = ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", + "Октябрь", "Ноябрь", "Декабрь"] +print(list[b]) \ No newline at end of file diff --git a/lesson_2/3.py b/lesson_2/3.py new file mode 100644 index 0000000..b3b7aa5 --- /dev/null +++ b/lesson_2/3.py @@ -0,0 +1,4 @@ +a = int(input("Введите месяц используя цифру от 1 до 12:")) +dict = {1: "Январь", 2: "Февраль", 3: "Март", 4: "Апрель", 5: "Май", 6: "Июнь", 7: "Июль", 8: "Август", 9: "Сентябрь", + 10: "Октябрь", 11: "Ноябрь", 12: "Декабрь"} +print(dict.get(a)) \ No newline at end of file diff --git a/lesson_2/4.py b/lesson_2/4.py new file mode 100644 index 0000000..e89215c --- /dev/null +++ b/lesson_2/4.py @@ -0,0 +1,4 @@ +list_1 = input("Ведите строку из нескольких слов:").split() +print(list_1) +for i, el in enumerate(list_1, 1): + print(f'{i}. {el[:10]}') \ No newline at end of file diff --git a/lesson_2/5.py b/lesson_2/5.py new file mode 100644 index 0000000..f7e5f04 --- /dev/null +++ b/lesson_2/5.py @@ -0,0 +1,5 @@ +list_1 = [9, 8, 7, 6, 5, 4, 3, 2, 1] +a = int(input("Ведите новый элемент списка:")) +list_1.append(a) +list_2 = sorted(list_1, reverse=True) +print(list_2) \ No newline at end of file diff --git a/lesson_3/.idea/.gitignore b/lesson_3/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/lesson_3/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/lesson_3/.idea/inspectionProfiles/profiles_settings.xml b/lesson_3/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/lesson_3/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/lesson_3/.idea/lesson_3.iml b/lesson_3/.idea/lesson_3.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/lesson_3/.idea/lesson_3.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lesson_3/.idea/misc.xml b/lesson_3/.idea/misc.xml new file mode 100644 index 0000000..d1e22ec --- /dev/null +++ b/lesson_3/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/lesson_3/.idea/modules.xml b/lesson_3/.idea/modules.xml new file mode 100644 index 0000000..65f7084 --- /dev/null +++ b/lesson_3/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lesson_3/.idea/vcs.xml b/lesson_3/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/lesson_3/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lesson_3/1.py b/lesson_3/1.py new file mode 100644 index 0000000..79a7dbf --- /dev/null +++ b/lesson_3/1.py @@ -0,0 +1,8 @@ +def my_f(s_1, s_2): + try: + sub = s_1 / s_2 + except ZeroDivisionError: + return "Error!" + print(round (sub, 3)) + +my_f(int(input("s_1: ")), int(input("s_2: "))) \ No newline at end of file diff --git a/lesson_3/2.py b/lesson_3/2.py new file mode 100644 index 0000000..d22aa3c --- /dev/null +++ b/lesson_3/2.py @@ -0,0 +1,6 @@ +def my_f(Имя, Фамилия, Город, Телефон): + sub = Имя + " " + Фамилия + " " + Город + " " + Телефон + " " + print(sub) + + +my_f (input("Имя: "), input("Фамилия: "), input("Город: "), input("Телефон: ")) \ No newline at end of file diff --git a/lesson_3/3.py b/lesson_3/3.py new file mode 100644 index 0000000..6b8e409 --- /dev/null +++ b/lesson_3/3.py @@ -0,0 +1,7 @@ +def my_f(s_1, s_2, s_3): + my_list = [s_1, s_2, s_3] + sub = s_1 + s_2 + s_3 - min(my_list) + print(sub) + + +my_f (int(input("s_1: ")), int(input("s_2: ")), int(input("s_3: "))) \ No newline at end of file diff --git a/lesson_3/4.py b/lesson_3/4.py new file mode 100644 index 0000000..669592b --- /dev/null +++ b/lesson_3/4.py @@ -0,0 +1,8 @@ +def my_f(s_1, s_2): + + sub = s_1 ** s_2 + print(sub) + + + +my_f (int(input("s_1: ")), int(input("s_2: "))) \ No newline at end of file diff --git a/lesson_3/5.py b/lesson_3/5.py new file mode 100644 index 0000000..68933d7 --- /dev/null +++ b/lesson_3/5.py @@ -0,0 +1,15 @@ +def sum_num(): + s = 0 + while True: + in_list = input("Введите число, `q` для выхода:").split() + for num in in_list: + if num == "q": + return s + else: + try: + s += int(num) + except ValueError: + print("Для выхода из программы, нажмите `q`: ") + print(f"Сумма чисел = {s}") + +print(sum_num()) \ No newline at end of file diff --git a/lesson_3/6.py b/lesson_3/6.py new file mode 100644 index 0000000..52ce116 --- /dev/null +++ b/lesson_3/6.py @@ -0,0 +1,10 @@ +def int_func(): + for word in input("Введите слова через пробел в нижнем регистре:\n").split(): + chars = 0 + for char in word: + if 97 <= ord(char) <= 122: + chars += 1 + print(word.title() if chars == len(word) else f"{word} - Используйте нижний регистр!") + + +int_func() \ No newline at end of file diff --git a/lesson_4/.idea/.gitignore b/lesson_4/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/lesson_4/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/lesson_4/.idea/inspectionProfiles/profiles_settings.xml b/lesson_4/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/lesson_4/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/lesson_4/.idea/lesson_4.iml b/lesson_4/.idea/lesson_4.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/lesson_4/.idea/lesson_4.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lesson_4/.idea/misc.xml b/lesson_4/.idea/misc.xml new file mode 100644 index 0000000..d1e22ec --- /dev/null +++ b/lesson_4/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/lesson_4/.idea/modules.xml b/lesson_4/.idea/modules.xml new file mode 100644 index 0000000..e957f45 --- /dev/null +++ b/lesson_4/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lesson_4/.idea/vcs.xml b/lesson_4/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/lesson_4/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lesson_4/1.py b/lesson_4/1.py new file mode 100644 index 0000000..624300e --- /dev/null +++ b/lesson_4/1.py @@ -0,0 +1,11 @@ +from sys import argv + +name, s_1, s_2, = argv +s_1 = int(s_1) +s_2 = int(s_2) +s_3 = s_1 * s_2 * 0.2 + +print("Выработка в часах: ", s_1) +print("Ставка в час: ", s_2) +print("Премия: ", s_3) +print("Зарплата: ", float((s_1 * s_2)+s_3)) \ No newline at end of file diff --git a/lesson_4/2.py b/lesson_4/2.py new file mode 100644 index 0000000..a88bb44 --- /dev/null +++ b/lesson_4/2.py @@ -0,0 +1,3 @@ +my_list = [300, 2, 12, 44, 1, 1, 4, 10, 7, 1, 78, 123, 55] +new_list = [my_list[num] for num in range(1, len(my_list)) if my_list[num] > my_list[num - 1]] +print(new_list) \ No newline at end of file diff --git a/lesson_4/3.py b/lesson_4/3.py new file mode 100644 index 0000000..8654224 --- /dev/null +++ b/lesson_4/3.py @@ -0,0 +1,3 @@ +my_list = [num for num in range(20, 241) if num % 20 == 0 or num % 21 == 0] + +print(my_list) \ No newline at end of file diff --git a/lesson_4/4.py b/lesson_4/4.py new file mode 100644 index 0000000..fe47a20 --- /dev/null +++ b/lesson_4/4.py @@ -0,0 +1,7 @@ +from random import randint + +my_list = [randint(1, 10) for _ in range(20)] +new_list = [num for num in my_list if my_list.count(num) == 1] + +print(my_list) +print(new_list) \ No newline at end of file diff --git a/lesson_4/5.py b/lesson_4/5.py new file mode 100644 index 0000000..e107798 --- /dev/null +++ b/lesson_4/5.py @@ -0,0 +1,7 @@ +from functools import reduce + + +my_list = [num for num in range(100, 1001, 2)] +s_1 = reduce(lambda x,y: x * y, my_list) +print(my_list) +print(s_1) \ No newline at end of file diff --git a/lesson_4/6.py b/lesson_4/6.py new file mode 100644 index 0000000..e0247ac --- /dev/null +++ b/lesson_4/6.py @@ -0,0 +1,12 @@ +from itertools import count +from itertools import cycle + +my_count = count(7) + +for _ in range(10): + print((next(my_count))) + +my_cycle = cycle("abc") + +for _ in range(10): + print((next(my_cycle))) \ No newline at end of file diff --git a/lesson_4/7.py b/lesson_4/7.py new file mode 100644 index 0000000..222c817 --- /dev/null +++ b/lesson_4/7.py @@ -0,0 +1,10 @@ +def fact_gen(number): + f_num = 1 + if number == 0: + yield f"{number}! = 1" + for i in range(1, number + 1): + f_num *= i + yield f"{i}! = {f_num}" + +for el in fact_gen(int(input("Factorial number:"))): + print(el) \ No newline at end of file