From c52f872fa66adad31dc26fe3c3794df7aee5cf40 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Sun, 27 Feb 2022 19:46:25 +0300
Subject: [PATCH 1/9] Something wrong (have to thing)
---
Lesson_3/task_1.py | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 Lesson_3/task_1.py
diff --git a/Lesson_3/task_1.py b/Lesson_3/task_1.py
new file mode 100644
index 0000000..8090413
--- /dev/null
+++ b/Lesson_3/task_1.py
@@ -0,0 +1,16 @@
+#Реализовать функцию, принимающую два числа (позиционные аргументы)
+#и выполняющую их деление. Числа запрашивать у пользователя,
+# предусмотреть обработку ситуации деления на ноль.
+
+def my_func(arg_1, arg_2):
+
+ try:
+ arg_1 = int(input('Please enter a number greater than 0: '))
+ arg_2 = int(input('Please enter a divider (not 0): '))
+ result = arg_1 / arg_2
+ except ValueError:
+ return 'Wrong value. Try again. Value should be a digit'
+ except ZeroDivisionError:
+ return 'Incorrect divider! Divider cannot be 0'
+
+ return result
\ No newline at end of file
From 6e7064678021b139fccbf0a46adc0150dccd262f Mon Sep 17 00:00:00 2001
From: Pavel
Date: Sun, 27 Feb 2022 19:54:11 +0300
Subject: [PATCH 2/9] Corrected (forgot to print the results).
---
Lesson_3/task_1.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/Lesson_3/task_1.py b/Lesson_3/task_1.py
index 8090413..51b6c5c 100644
--- a/Lesson_3/task_1.py
+++ b/Lesson_3/task_1.py
@@ -2,10 +2,10 @@
#и выполняющую их деление. Числа запрашивать у пользователя,
# предусмотреть обработку ситуации деления на ноль.
-def my_func(arg_1, arg_2):
+def my_div(*args):
try:
- arg_1 = int(input('Please enter a number greater than 0: '))
+ arg_1 = int(input('Please enter a number (greater than 0): '))
arg_2 = int(input('Please enter a divider (not 0): '))
result = arg_1 / arg_2
except ValueError:
@@ -13,4 +13,6 @@ def my_func(arg_1, arg_2):
except ZeroDivisionError:
return 'Incorrect divider! Divider cannot be 0'
- return result
\ No newline at end of file
+ return result
+
+print(f'result {my_div()}')
\ No newline at end of file
From b4554953fab4b204c8025aed10735ccd3a3d6d23 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Sun, 27 Feb 2022 20:00:17 +0300
Subject: [PATCH 3/9] Added some edits.
---
Lesson_3/task_1.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Lesson_3/task_1.py b/Lesson_3/task_1.py
index 51b6c5c..1ce3d56 100644
--- a/Lesson_3/task_1.py
+++ b/Lesson_3/task_1.py
@@ -1,9 +1,8 @@
-#Реализовать функцию, принимающую два числа (позиционные аргументы)
-#и выполняющую их деление. Числа запрашивать у пользователя,
+# Реализовать функцию, принимающую два числа (позиционные аргументы)
+# и выполняющую их деление. Числа запрашивать у пользователя,
# предусмотреть обработку ситуации деления на ноль.
def my_div(*args):
-
try:
arg_1 = int(input('Please enter a number (greater than 0): '))
arg_2 = int(input('Please enter a divider (not 0): '))
@@ -15,4 +14,5 @@ def my_div(*args):
return result
-print(f'result {my_div()}')
\ No newline at end of file
+
+print(f'result {my_div()}')
From 6e97791461da3a67ebeebf984591783277ee4c8d Mon Sep 17 00:00:00 2001
From: Pavel
Date: Sun, 27 Feb 2022 20:26:53 +0300
Subject: [PATCH 4/9] First variant doesn't work. Need to think.
---
Lesson_3/task_2.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
create mode 100644 Lesson_3/task_2.py
diff --git a/Lesson_3/task_2.py b/Lesson_3/task_2.py
new file mode 100644
index 0000000..4ef22f4
--- /dev/null
+++ b/Lesson_3/task_2.py
@@ -0,0 +1,18 @@
+# Выполнить функцию, которая принимает несколько параметров, описывающих
+# данные пользователя: имя, фамилия, год рождения, город проживания, email,
+# телефон. Функция должна принимать параметры как именованные аргументы.
+# Осуществить вывод данных о пользователе одной строкой.
+
+name = input('Please enter your name: ')
+surname = input('Please enter your surname: ')
+birthday = int(input('Please enter your birth year: '))
+location = input('Please enter your city of residence: ')
+email = input('Please enter your email address: ')
+phone = int(input('Please enter your phone number: '))
+
+
+def mfunc(name, surname, birthday, location, email, phone):
+ return ' '.join([name, surname, birthday, location, email, phone])
+
+
+print(mfunc(name=' ', surname=' ', birthday=' ', location=' ', email=' ', phone=' '))
From 48d9816440e73bcde627ff37ccbddfd8d1c44b28 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Sun, 27 Feb 2022 22:09:03 +0300
Subject: [PATCH 5/9] more or less works.
---
Lesson_3/task_2.py | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/Lesson_3/task_2.py b/Lesson_3/task_2.py
index 4ef22f4..5a7199a 100644
--- a/Lesson_3/task_2.py
+++ b/Lesson_3/task_2.py
@@ -3,16 +3,13 @@
# телефон. Функция должна принимать параметры как именованные аргументы.
# Осуществить вывод данных о пользователе одной строкой.
-name = input('Please enter your name: ')
-surname = input('Please enter your surname: ')
-birthday = int(input('Please enter your birth year: '))
-location = input('Please enter your city of residence: ')
-email = input('Please enter your email address: ')
-phone = int(input('Please enter your phone number: '))
-
-
def mfunc(name, surname, birthday, location, email, phone):
return ' '.join([name, surname, birthday, location, email, phone])
-print(mfunc(name=' ', surname=' ', birthday=' ', location=' ', email=' ', phone=' '))
+print(mfunc(name=input('Please enter your name: '),
+ surname=input('Please enter your surname: '),
+ birthday=input('Please enter your birth year: '),
+ location=input('Please enter your city of residence: '),
+ email=input('Please enter your email address: '),
+ phone=input('Please enter your phone number: ')))
From b11f5a658440405ff54361b12b6d420832d4466b Mon Sep 17 00:00:00 2001
From: Pavel
Date: Sun, 27 Feb 2022 22:42:46 +0300
Subject: [PATCH 6/9] Completed.
---
Lesson_3/task_3.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
create mode 100644 Lesson_3/task_3.py
diff --git a/Lesson_3/task_3.py b/Lesson_3/task_3.py
new file mode 100644
index 0000000..20cf358
--- /dev/null
+++ b/Lesson_3/task_3.py
@@ -0,0 +1,18 @@
+# Реализовать функцию my_func(), которая принимает
+# три позиционных аргумента и возвращает сумму наибольших
+# двух аргументов.
+
+def mfunc(arg_1, arg_2, arg_3):
+ # arg_1 = int(input('Please enter the first value: '))
+ # arg_2 = int(input('Please enter the second value: '))
+ # arg_3 = int(input('Please enter the third value: '))
+
+ if arg_1 >= arg_2 and arg_2 >= arg_3:
+ return arg_1 + arg_2
+ elif arg_3 >= arg_2 and arg_2 >= arg_1:
+ return arg_2 + arg_3
+ else:
+ return arg_1 + arg_3
+
+
+print(f"result {mfunc(int(input('Please enter the first value: ')), int(input('Please enter the second value: ')), int(input('Please enter the third value: ')))}")
From 14cf7874d501fffed4e9f84134fbb14d3f2079f0 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Tue, 1 Mar 2022 13:11:07 +0300
Subject: [PATCH 7/9] Completed.
---
Lesson_3/task_4.py | 9 +++++++++
1 file changed, 9 insertions(+)
create mode 100644 Lesson_3/task_4.py
diff --git a/Lesson_3/task_4.py b/Lesson_3/task_4.py
new file mode 100644
index 0000000..c4bd844
--- /dev/null
+++ b/Lesson_3/task_4.py
@@ -0,0 +1,9 @@
+# Программа принимает действительное положительное число x и целое отрицательное число y.
+# Выполните возведение числа x в степень y. Задание реализуйте в виде функции my_func(x, y).
+# При решении задания нужно обойтись без встроенной функции возведения числа в степень.
+
+def my_func(x, y):
+ return x ** y
+
+
+print(f"{my_func(int(input('Please enter a valid positive number (X): ')), int(input('Enter a negative integer (Y): ')))}")
From 99a02d342a2e21832728fe0e110fcc9c8b24707c Mon Sep 17 00:00:00 2001
From: Pavel
Date: Tue, 1 Mar 2022 17:10:47 +0300
Subject: [PATCH 8/9] Completed.
---
Lesson_3/task_5.py | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
create mode 100644 Lesson_3/task_5.py
diff --git a/Lesson_3/task_5.py b/Lesson_3/task_5.py
new file mode 100644
index 0000000..23b74fc
--- /dev/null
+++ b/Lesson_3/task_5.py
@@ -0,0 +1,26 @@
+# Программа запрашивает у пользователя строку чисел, разделённых пробелом.
+# При нажатии Enter должна выводиться сумма чисел. Пользователь может продолжить ввод чисел,
+# разделённых пробелом и снова нажать Enter. Сумма вновь введённых чисел будет добавляться
+# к уже подсчитанной сумме. Но если вместо числа вводится специальный символ, выполнение
+# программы завершается. Если специальный символ введён после нескольких чисел,
+# то вначале нужно добавить сумму этих чисел к полученной ранее сумме и после этого завершить программу.
+
+def msum():
+ sumres = 0
+ exit = False
+ while exit == False:
+ num = input("Please enter a value or a special symbol '!' to exit: ").split()
+
+ res = 0
+ for i in range(len(num)):
+ if num[i] == '!':
+ exit = True
+ break
+ else:
+ res = res + int(num[i])
+ sumres = sumres + res
+ print(f'Intermediate sum value is {sumres}')
+ print(f'Final value of sum {sumres}')
+
+
+msum()
From f995c5f76aa94e99f9476260f1565b1671b95a60 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Tue, 1 Mar 2022 17:22:03 +0300
Subject: [PATCH 9/9] Completed.
---
Lesson_3/task_6.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
create mode 100644 Lesson_3/task_6.py
diff --git a/Lesson_3/task_6.py b/Lesson_3/task_6.py
new file mode 100644
index 0000000..21d6fc3
--- /dev/null
+++ b/Lesson_3/task_6.py
@@ -0,0 +1,12 @@
+# Реализовать функцию int_func(), принимающую слова из маленьких латинских букв
+# и возвращающую их же, но с прописной первой буквой.
+# Например, print(int_func(‘text’)) -> Text.
+
+def mfunc(*args):
+ mtext = input('Please enter a short text: ')
+ print(mtext.title())
+ return
+
+
+mfunc()
+