From 8381966fbce9f4b4bcd006939dec4a671e3f2ee9 Mon Sep 17 00:00:00 2001 From: "Serebryakov.AO" Date: Fri, 9 Apr 2021 01:12:11 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=82=D1=80=D0=B5=D1=82=D1=8C=D0=B5=D0=B3?= =?UTF-8?q?=D0=BE=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- task1.py | 12 ++++++++++++ task2.py | 16 ++++++++++++++++ task3.py | 6 ++++++ task4.py | 11 +++++++++++ task5.py | 13 +++++++++++++ task6.py | 11 +++++++++++ 6 files changed, 69 insertions(+) create mode 100644 task1.py create mode 100644 task2.py create mode 100644 task3.py create mode 100644 task4.py create mode 100644 task5.py create mode 100644 task6.py diff --git a/task1.py b/task1.py new file mode 100644 index 0000000..584ff72 --- /dev/null +++ b/task1.py @@ -0,0 +1,12 @@ +# функция, принимающаю два числа (позиционные аргументы) и выполняющую их деление +def my_del(num1, num2): + if num2 == '0': + error = 'Нельзя делить на 0!' + return 'Ошибка: ' + error + return float(num1) / float(num2) + + +while True: + a = input('Введите делимое: ') + b = input('Введите делитель: ') + print(my_del(a, b)) diff --git a/task2.py b/task2.py new file mode 100644 index 0000000..f0cbd13 --- /dev/null +++ b/task2.py @@ -0,0 +1,16 @@ +# функция, принимающая несколько параметров, описывающих данные пользователя + +def user_data(name, s_name, b_year, city, email, phone): + print(f'Имя: {name}, фамилия: {s_name}, год рождения: {b_year}, город проживания: {city}, email: {email},' \ + f' телефон: {phone}') + +while True: + print('Введите данные пользователя: ') + user_data( + name=input('Имя: '), + city=input('город проживания: '), + email=input('email: '), + phone=input('телефон: '), + s_name=input('фамилия: '), + b_year=input('год рождения: ') + ) diff --git a/task3.py b/task3.py new file mode 100644 index 0000000..12bb836 --- /dev/null +++ b/task3.py @@ -0,0 +1,6 @@ +def my_func(arg1, arg2, arg3): + my_list = [arg1, arg2, arg3] + my_list.remove(min(my_list)) + return sum(my_list) + +print(my_func(10, 2, 3)) diff --git a/task4.py b/task4.py new file mode 100644 index 0000000..976e05d --- /dev/null +++ b/task4.py @@ -0,0 +1,11 @@ +def my_pow_2(x, y): + r = x + while y > 1: + r = r * x + y -= 1 + return r + + +print(my_pow_2(2, 8)) +my_pow = lambda x, y: x**y +print(my_pow(2, 8)) diff --git a/task5.py b/task5.py new file mode 100644 index 0000000..39ab761 --- /dev/null +++ b/task5.py @@ -0,0 +1,13 @@ +my_sum = 0 + +def my_calc(str_numbers): + my_list = str_numbers.split() + my_list = list(map(int, my_list)) + return sum(my_list, my_sum) + + +while True: + numbers = input('Введите числа через пробел') + my_sum = my_calc(numbers) + print(my_sum) + diff --git a/task6.py b/task6.py new file mode 100644 index 0000000..41439db --- /dev/null +++ b/task6.py @@ -0,0 +1,11 @@ +def my_title(words): + list_words = words.split() + return ' '.join(list(map(int_func, list_words))) + + +def int_func(word): + letters = list(word) + letters[0] = letters[0].upper() + return ''.join(letters) + +print(my_title('test func etc')) \ No newline at end of file