From 4b7b70c4f454b565d25ea28b35df69bc14ec7618 Mon Sep 17 00:00:00 2001
From: PaLoLegych
Date: Mon, 14 Feb 2022 10:11:42 +0300
Subject: [PATCH 01/21] Hello world (python)
---
Hello.py | 1 +
1 file changed, 1 insertion(+)
create mode 100644 Hello.py
diff --git a/Hello.py b/Hello.py
new file mode 100644
index 0000000..8eb74cf
--- /dev/null
+++ b/Hello.py
@@ -0,0 +1 @@
+print('Hello world')
\ No newline at end of file
From f33b103f755163e3c9241e610a97740f14d15e00 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Fri, 18 Feb 2022 14:29:02 +0300
Subject: [PATCH 02/21] connection test
---
Lesson_1/.idea/.gitignore | 3 +++
Lesson_1/.idea/Lesson_1.iml | 10 ++++++++++
.../inspectionProfiles/profiles_settings.xml | 6 ++++++
Lesson_1/.idea/misc.xml | 4 ++++
Lesson_1/.idea/modules.xml | 8 ++++++++
Lesson_1/.idea/vcs.xml | 6 ++++++
Lesson_1/info.py | 16 ++++++++++++++++
Lesson_1/task_1.py | 1 +
Lesson_1/task_2.py | 0
9 files changed, 54 insertions(+)
create mode 100644 Lesson_1/.idea/.gitignore
create mode 100644 Lesson_1/.idea/Lesson_1.iml
create mode 100644 Lesson_1/.idea/inspectionProfiles/profiles_settings.xml
create mode 100644 Lesson_1/.idea/misc.xml
create mode 100644 Lesson_1/.idea/modules.xml
create mode 100644 Lesson_1/.idea/vcs.xml
create mode 100644 Lesson_1/info.py
create mode 100644 Lesson_1/task_1.py
create mode 100644 Lesson_1/task_2.py
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/Lesson_1.iml b/Lesson_1/.idea/Lesson_1.iml
new file mode 100644
index 0000000..74d515a
--- /dev/null
+++ b/Lesson_1/.idea/Lesson_1.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
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/misc.xml b/Lesson_1/.idea/misc.xml
new file mode 100644
index 0000000..a4652f3
--- /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..a04d3c7
--- /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/info.py b/Lesson_1/info.py
new file mode 100644
index 0000000..94e3a87
--- /dev/null
+++ b/Lesson_1/info.py
@@ -0,0 +1,16 @@
+# This is a sample Python script.
+
+# Press ⌃R to execute it or replace it with your code.
+# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
+
+
+def print_hi(name):
+ # Use a breakpoint in the code line below to debug your script.
+ print(f'Hi, {name}') # Press ⌘F8 to toggle the breakpoint.
+
+
+# Press the green button in the gutter to run the script.
+if __name__ == '__main__':
+ print_hi('PyCharm')
+
+# See PyCharm help at https://www.jetbrains.com/help/pycharm/
diff --git a/Lesson_1/task_1.py b/Lesson_1/task_1.py
new file mode 100644
index 0000000..314b8ac
--- /dev/null
+++ b/Lesson_1/task_1.py
@@ -0,0 +1 @@
+print(5*5)
\ No newline at end of file
diff --git a/Lesson_1/task_2.py b/Lesson_1/task_2.py
new file mode 100644
index 0000000..e69de29
From f4fd7e8521abd3e4ebba1b3dec02e2c4d23f86f5 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Fri, 18 Feb 2022 15:34:30 +0300
Subject: [PATCH 03/21] The solution of the first task was added
---
Lesson_1/task_1.py | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/Lesson_1/task_1.py b/Lesson_1/task_1.py
index 314b8ac..17d8abb 100644
--- a/Lesson_1/task_1.py
+++ b/Lesson_1/task_1.py
@@ -1 +1,19 @@
-print(5*5)
\ No newline at end of file
+print(
+ 'Поработайте с переменными, создайте несколько, выведите на экран. Запросите у пользователя некоторые числа и строки и сохраните в переменные, затем выведите на экран.')
+a = 10
+b = 45.23
+c = a + b
+d = a - b
+x = c / d
+print(a)
+print(b)
+print(c)
+print(d)
+print(x)
+
+name = input('Please, enter your name: ')
+print("Hi, %s!" % name)
+i = int(input(name + ' please, enter a random number: '))
+a = i + i * i
+print('Thank you very much. The answer is:')
+print(a)
From 5e96983f4875bc4b2ff618f5f63eb3612abb062a Mon Sep 17 00:00:00 2001
From: Pavel
Date: Fri, 18 Feb 2022 16:47:45 +0300
Subject: [PATCH 04/21] The solution of the second task was added
---
Lesson_1/task_2.py | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Lesson_1/task_2.py b/Lesson_1/task_2.py
index e69de29..043e18f 100644
--- a/Lesson_1/task_2.py
+++ b/Lesson_1/task_2.py
@@ -0,0 +1,8 @@
+# Пользователь вводит время в секундах.
+# Переведите время в часы, минуты, секунды и выведите в формате чч:мм:сс.
+# Используйте форматирование строк.
+Interval = int(input('Please, enter the time interval in seconds: '))
+H = Interval // 3600
+M = (Interval - H * 3600) // 60
+S = Interval - (H * 3600 + M * 60)
+input('If your time interval is equal to %d than the current time is: ' % (Interval) + '%02d:%02d:%02d' % (H, M, S))
From 28c8e8d98035b9b3e9026b71df0e2e2f102a6cd1 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Fri, 18 Feb 2022 16:57:33 +0300
Subject: [PATCH 05/21] A small deign revision
---
Lesson_1/task_1.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Lesson_1/task_1.py b/Lesson_1/task_1.py
index 17d8abb..7f49dd0 100644
--- a/Lesson_1/task_1.py
+++ b/Lesson_1/task_1.py
@@ -1,5 +1,6 @@
-print(
- 'Поработайте с переменными, создайте несколько, выведите на экран. Запросите у пользователя некоторые числа и строки и сохраните в переменные, затем выведите на экран.')
+# Поработайте с переменными, создайте несколько, выведите на экран.
+# Запросите у пользователя некоторые числа и строки и сохраните в переменные,
+# затем выведите на экран.
a = 10
b = 45.23
c = a + b
From 63a37580b4ffcb3df869a25c4699b67860914259 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Sat, 19 Feb 2022 18:14:45 +0300
Subject: [PATCH 06/21] The result of the task 3
---
Lesson_1/task_3.py | 11 +++++++++++
1 file changed, 11 insertions(+)
create mode 100644 Lesson_1/task_3.py
diff --git a/Lesson_1/task_3.py b/Lesson_1/task_3.py
new file mode 100644
index 0000000..e7a3517
--- /dev/null
+++ b/Lesson_1/task_3.py
@@ -0,0 +1,11 @@
+# Узнайте у пользователя число n.
+# Найдите сумму чисел n + nn + nnn.
+# Например, пользователь ввёл число 3.
+# Считаем 3 + 33 + 333 = 369.
+
+n = int(input('Please, enter a random value = '))
+x = str(n)
+nn = x + x
+nnn = x + x + x
+cal = n + int(nn) + int(nnn)
+print('Based on your value: %d ' % n + 'the result of the calculation is = %d' % cal)
From 8230f6d578efbc53e476c01ad4f69bd57a4ab895 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Sat, 19 Feb 2022 18:17:57 +0300
Subject: [PATCH 07/21] Added some changes in "print()"
---
Lesson_1/task_1.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/Lesson_1/task_1.py b/Lesson_1/task_1.py
index 7f49dd0..33c38c9 100644
--- a/Lesson_1/task_1.py
+++ b/Lesson_1/task_1.py
@@ -14,7 +14,6 @@
name = input('Please, enter your name: ')
print("Hi, %s!" % name)
-i = int(input(name + ' please, enter a random number: '))
+i = int(input('Please, enter a random number: '))
a = i + i * i
-print('Thank you very much. The answer is:')
-print(a)
+print('Thank you very much. The answer is: %d' %a)
From dddf7ed4bab30482423c7dd427667337f21a6067 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Sat, 19 Feb 2022 20:05:04 +0300
Subject: [PATCH 08/21] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0?=
=?UTF-8?q?=D0=B5=D1=82,=20=D0=BD=D0=BE=20=D0=BE=D1=87=D0=B5=D0=BD=D1=8C?=
=?UTF-8?q?=20=D0=BA=D0=BE=D1=80=D1=8F=D0=B2=D0=BE.=20=D0=9D=D1=83=D0=B6?=
=?UTF-8?q?=D0=BD=D0=BE=20=D1=80=D0=B0=D0=B7=D0=B1=D0=B8=D1=80=D0=B0=D1=82?=
=?UTF-8?q?=D1=8C=D1=81=D1=8F.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Lesson_1/task_4.py | 11 +++++++++++
1 file changed, 11 insertions(+)
create mode 100644 Lesson_1/task_4.py
diff --git a/Lesson_1/task_4.py b/Lesson_1/task_4.py
new file mode 100644
index 0000000..7015660
--- /dev/null
+++ b/Lesson_1/task_4.py
@@ -0,0 +1,11 @@
+# Пользователь вводит целое положительное число.
+# Найдите самую большую цифру в числе.
+# Для решения используйте цикл while и арифметические операции.
+val = int(input('Please, enter positive value: '))
+max_val = val % 10
+while val > 0:
+ val = val // 10
+ if val > max_val:
+ max_val = val % 10
+ print('The largest digit in %d ' % val + 'is = %d' % max_val)
+ break
From 87b1ad0c1e4f0f77836d790ce5f276fe05336a55 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Sat, 19 Feb 2022 20:48:17 +0300
Subject: [PATCH 09/21] The result of the task 5
---
Lesson_1/task_5.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
create mode 100644 Lesson_1/task_5.py
diff --git a/Lesson_1/task_5.py b/Lesson_1/task_5.py
new file mode 100644
index 0000000..3ebe687
--- /dev/null
+++ b/Lesson_1/task_5.py
@@ -0,0 +1,18 @@
+# Запросите у пользователя значения выручки и издержек фирмы.
+# Определите, с каким финансовым результатом работает фирма.
+# Например, прибыль — выручка больше издержек,
+# или убыток — издержки больше выручки. Выведите соответствующее сообщение.
+# Если фирма отработала с прибылью, вычислите рентабельность выручки. Э
+# то отношение прибыли к выручке. Далее запросите численность сотрудников
+# фирмы и определите прибыль фирмы в расчёте на одного сотрудника.
+
+rev = float(input('Please enter revenue of the company: '))
+cos = float(input('Please enter costs of the company: '))
+inc = rev - cos
+if inc > 0:
+ print('The company is profitable.')
+ print(f'Return on revenue is: {inc / rev: .2f}')
+ staff = int(input('Please enter the number of employees:'))
+ print(f'Profit per employee is: {rev / staff: .2f}')
+else:
+ print('The company is unprofitable.')
From 955736211a5894d6ded5425502f49926015d409f Mon Sep 17 00:00:00 2001
From: Pavel
Date: Sun, 20 Feb 2022 12:23:06 +0300
Subject: [PATCH 10/21] The code was edited (mistakes correction).
---
Lesson_1/task_4.py | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/Lesson_1/task_4.py b/Lesson_1/task_4.py
index 7015660..1474b41 100644
--- a/Lesson_1/task_4.py
+++ b/Lesson_1/task_4.py
@@ -3,9 +3,12 @@
# Для решения используйте цикл while и арифметические операции.
val = int(input('Please, enter positive value: '))
max_val = val % 10
-while val > 0:
- val = val // 10
- if val > max_val:
- max_val = val % 10
- print('The largest digit in %d ' % val + 'is = %d' % max_val)
- break
+num = val
+while num > 0:
+ dgt = num % 10
+ if dgt > max_val:
+ max_val = dgt
+ if max_val == 9:
+ break
+ num = num // 10
+print(f'The largest digit in {val} is = {max_val}')
From 55ada124c89c2d3022f0ab695c8d1aeddf1e2f01 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Sun, 20 Feb 2022 12:45:08 +0300
Subject: [PATCH 11/21] The results of the task 6
---
Lesson_1/task_6.py | 15 +++++++++++++++
1 file changed, 15 insertions(+)
create mode 100644 Lesson_1/task_6.py
diff --git a/Lesson_1/task_6.py b/Lesson_1/task_6.py
new file mode 100644
index 0000000..3c8bbac
--- /dev/null
+++ b/Lesson_1/task_6.py
@@ -0,0 +1,15 @@
+# Спортсмен занимается ежедневными пробежками.
+# В первый день его результат составил a километров.
+# Каждый день спортсмен увеличивал результат
+# на 10% относительно предыдущего. Требуется определить номер дня,
+# на который результат спортсмена составит не менее b километров.
+# Программа должна принимать значения параметров a и b и
+# выводить одно натуральное число — номер дня.
+
+a = int(input('Please enter the current distance value '))
+b = int(input('Please enter the distance you would like to run '))
+ad = 1 # ad = amount of the days
+while a < b:
+ a = 1.1 * a
+ ad += 1
+print(f'If you increase your distance by 10% you will be able to run2 {b} km in {ad} days')
\ No newline at end of file
From 22aa221329a295c5263511da9169bf45cece6e21 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Mon, 21 Feb 2022 21:57:55 +0300
Subject: [PATCH 12/21] The first version of the code. Wanted to write a code
with a request to enter data for a dictionary, but the input does not pass
(need to think about how to implement this).
---
Lesson_2/task_1.py | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 Lesson_2/task_1.py
diff --git a/Lesson_2/task_1.py b/Lesson_2/task_1.py
new file mode 100644
index 0000000..688e473
--- /dev/null
+++ b/Lesson_2/task_1.py
@@ -0,0 +1,8 @@
+# Создать список и заполнить его элементами различных типов данных.
+# Реализовать скрипт проверки типа данных каждого элемента.
+# Использовать функцию type() для проверки типа.
+# Элементы списка можно не запрашивать у пользователя, а указать явно, в программе.
+
+main_list = [56, 3.76, False, "Hello", ('2', 'a', '6'), ['b', '3', 'c'], {'123': 'key-1', '321': 'key-2'}]
+for i in main_list:
+ print(f'{i} is {type(i)}')
From bb13d78e1fd5be0c74c9eaa64e7d5fc3e15ea243 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Tue, 22 Feb 2022 13:01:59 +0300
Subject: [PATCH 13/21] The first version of the code. It is not clear why the
last digit in the even version of the list does not change places (need to
think about).
---
Lesson_2/task_2.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 Lesson_2/task_2.py
diff --git a/Lesson_2/task_2.py b/Lesson_2/task_2.py
new file mode 100644
index 0000000..680b8e1
--- /dev/null
+++ b/Lesson_2/task_2.py
@@ -0,0 +1,21 @@
+# Для списка реализовать обмен значений соседних элементов.
+# Значениями обмениваются элементы с индексами 0 и 1, 2 и 3 и т. д.
+# При нечётном количестве элементов последний сохранить на своём месте.
+# Для заполнения списка элементов нужно использовать функцию input().
+
+list_init = int(input('Please, enter the elements number '))
+my_list1 = []
+i = 0
+# el = 0
+while i < list_init:
+ my_list1.extend(input('Please, enter the element value '))
+ i += 1
+
+print(my_list1)
+
+my_list2 = my_list1
+
+for el in range(int(len(my_list2) / 2)):
+ my_list2[el + 1], my_list2[el] = my_list2[el], my_list2[el + 1]
+ el += 2
+print(my_list2)
From 13b5afc98f5917dfcabd966728209d96247e7978 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Tue, 22 Feb 2022 15:19:54 +0300
Subject: [PATCH 14/21] =?UTF-8?q?The=20first=20version=20of=20the=20code.?=
=?UTF-8?q?=20I=20didn=E2=80=99t=20figure=20out=20how=20to=20make=20both?=
=?UTF-8?q?=20a=20list=20and=20a=20dictionary=20(need=20to=20think=20about?=
=?UTF-8?q?).?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Lesson_2/task_3.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 Lesson_2/task_3.py
diff --git a/Lesson_2/task_3.py b/Lesson_2/task_3.py
new file mode 100644
index 0000000..4e08b38
--- /dev/null
+++ b/Lesson_2/task_3.py
@@ -0,0 +1,20 @@
+# Пользователь вводит месяц в виде целого числа от 1 до 12.
+# Сообщить, к какому времени года относится месяц (зима, весна, лето, осень).
+# Напишите решения через list и dict.
+
+m_dict = {'1': 'January', '2': 'February', '3': 'March',
+ '4': 'April', '5': 'May', '6': 'June',
+ '7': 'July', '8': 'August', '9': 'September',
+ '10': 'October', '11': 'November', '12': 'December'}
+num_m = int(input('Please enter a month number from 1 to 12: '))
+a = num_m
+if a == 1 or a == 2 or a == 12:
+ print("Your choiсe is the Winter season")
+elif a == 3 or a == 4 or a == 5:
+ print("Your choiсe is the Spring season")
+elif a == 6 or a == 7 or a == 8:
+ print("Your choiсe is the Summer season")
+elif a == 9 or a == 10 or a == 11:
+ print("Your choiсe is the Autumn season")
+else:
+ print("You made a mistake. Try again!")
From 8ec2618262368e3b6cca06489571e680e37596e9 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Thu, 24 Feb 2022 12:33:39 +0300
Subject: [PATCH 15/21] Some changes have been made to the code.
---
Lesson_2/task_2.py | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/Lesson_2/task_2.py b/Lesson_2/task_2.py
index 680b8e1..ed2c1ec 100644
--- a/Lesson_2/task_2.py
+++ b/Lesson_2/task_2.py
@@ -3,19 +3,20 @@
# При нечётном количестве элементов последний сохранить на своём месте.
# Для заполнения списка элементов нужно использовать функцию input().
-list_init = int(input('Please, enter the elements number '))
-my_list1 = []
-i = 0
-# el = 0
-while i < list_init:
- my_list1.extend(input('Please, enter the element value '))
- i += 1
-
-print(my_list1)
-
-my_list2 = my_list1
-
-for el in range(int(len(my_list2) / 2)):
- my_list2[el + 1], my_list2[el] = my_list2[el], my_list2[el + 1]
- el += 2
-print(my_list2)
+list_init = input('Please, enter the values separated by spaces: ').split()
+print(list_init)
+if len(list_init) % 2 == 0:
+ i = 0
+ while i < len(list_init):
+ el = list_init[i]
+ list_init[i] = list_init[i + 1]
+ list_init[i + 1] = el
+ i += 2
+else:
+ i = 0
+ while i < len(list_init) - 1:
+ el = list_init[i]
+ list_init[i] = list_init[i + 1]
+ list_init[i + 1] = el
+ i += 2
+print(list_init)
From d6c8f8f040f94a41f686cd5c81e80fbb1351cb55 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Thu, 24 Feb 2022 13:32:08 +0300
Subject: [PATCH 16/21] Some changes have been made to the code (added the
list).
---
Lesson_2/task_3.py | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/Lesson_2/task_3.py b/Lesson_2/task_3.py
index 4e08b38..e5bb0b9 100644
--- a/Lesson_2/task_3.py
+++ b/Lesson_2/task_3.py
@@ -2,19 +2,20 @@
# Сообщить, к какому времени года относится месяц (зима, весна, лето, осень).
# Напишите решения через list и dict.
-m_dict = {'1': 'January', '2': 'February', '3': 'March',
- '4': 'April', '5': 'May', '6': 'June',
- '7': 'July', '8': 'August', '9': 'September',
- '10': 'October', '11': 'November', '12': 'December'}
+m_list = ['Winter', 'Spring', 'Summer', 'Autumn']
+m_dict = {1: 'January', 2: 'February', 3: 'March',
+ 4: 'April', 5: 'May', 6: 'June',
+ 7: 'July', 8: 'August', 9: 'September',
+ 10: 'October', 11: 'November', 12: 'December'}
num_m = int(input('Please enter a month number from 1 to 12: '))
a = num_m
if a == 1 or a == 2 or a == 12:
- print("Your choiсe is the Winter season")
+ print('Your choiсe is', m_dict.get(num_m), 'it is', m_list[0], 'season')
elif a == 3 or a == 4 or a == 5:
- print("Your choiсe is the Spring season")
+ print('Your choiсe is', m_dict.get(num_m), 'it is', m_list[1], 'season')
elif a == 6 or a == 7 or a == 8:
- print("Your choiсe is the Summer season")
+ print('Your choiсe is', m_dict.get(num_m), 'it is', m_list[2], 'season')
elif a == 9 or a == 10 or a == 11:
- print("Your choiсe is the Autumn season")
+ print('Your choiсe is', m_dict.get(num_m), 'it is', m_list[3], 'season')
else:
print("You made a mistake. Try again!")
From 4c3741272c5570e8ad72b59ecc4ff7b4cd1953e9 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Thu, 24 Feb 2022 14:02:36 +0300
Subject: [PATCH 17/21] Simple code.
---
Lesson_1/info.py | 16 ----------------
Lesson_2/task_4.py | 9 +++++++++
2 files changed, 9 insertions(+), 16 deletions(-)
delete mode 100644 Lesson_1/info.py
create mode 100644 Lesson_2/task_4.py
diff --git a/Lesson_1/info.py b/Lesson_1/info.py
deleted file mode 100644
index 94e3a87..0000000
--- a/Lesson_1/info.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# This is a sample Python script.
-
-# Press ⌃R to execute it or replace it with your code.
-# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
-
-
-def print_hi(name):
- # Use a breakpoint in the code line below to debug your script.
- print(f'Hi, {name}') # Press ⌘F8 to toggle the breakpoint.
-
-
-# Press the green button in the gutter to run the script.
-if __name__ == '__main__':
- print_hi('PyCharm')
-
-# See PyCharm help at https://www.jetbrains.com/help/pycharm/
diff --git a/Lesson_2/task_4.py b/Lesson_2/task_4.py
new file mode 100644
index 0000000..5726328
--- /dev/null
+++ b/Lesson_2/task_4.py
@@ -0,0 +1,9 @@
+# Пользователь вводит строку из нескольких слов, разделённых пробелами.
+# Вывести каждое слово с новой строки. Строки нужно пронумеровать.
+# Если слово длинное, выводить только первые 10 букв в слове.
+
+my_str = input('Please enter some text with spaces between words: ')
+i = 0
+for my_str in my_str:
+ print(i, my_str)
+ i += 1
From 806e43adfd6761c484c129125ec0e4704447dd72 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Thu, 24 Feb 2022 14:43:11 +0300
Subject: [PATCH 18/21] Added some changes.
---
Lesson_2/task_4.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/Lesson_2/task_4.py b/Lesson_2/task_4.py
index 5726328..8afb6e5 100644
--- a/Lesson_2/task_4.py
+++ b/Lesson_2/task_4.py
@@ -3,7 +3,9 @@
# Если слово длинное, выводить только первые 10 букв в слове.
my_str = input('Please enter some text with spaces between words: ')
-i = 0
-for my_str in my_str:
- print(i, my_str)
- i += 1
+value = my_str.split()
+for i, el in enumerate(value):
+ if len(el) > 10:
+ el = el[0:10:1]
+ print(i, el)
+
From aba89021fcc4b490ee198df9201d89672ca1c968 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Thu, 24 Feb 2022 15:53:44 +0300
Subject: [PATCH 19/21] The first variant of the code. There is some bugs (need
to think).
---
Lesson_2/.idea/.gitignore | 3 ++
Lesson_2/.idea/Lesson_2.iml | 10 ++++++
.../inspectionProfiles/profiles_settings.xml | 6 ++++
Lesson_2/.idea/misc.xml | 4 +++
Lesson_2/.idea/modules.xml | 8 +++++
Lesson_2/.idea/vcs.xml | 6 ++++
Lesson_2/main.py | 16 +++++++++
Lesson_2/task_5.py | 34 +++++++++++++++++++
8 files changed, 87 insertions(+)
create mode 100644 Lesson_2/.idea/.gitignore
create mode 100644 Lesson_2/.idea/Lesson_2.iml
create mode 100644 Lesson_2/.idea/inspectionProfiles/profiles_settings.xml
create mode 100644 Lesson_2/.idea/misc.xml
create mode 100644 Lesson_2/.idea/modules.xml
create mode 100644 Lesson_2/.idea/vcs.xml
create mode 100644 Lesson_2/main.py
create mode 100644 Lesson_2/task_5.py
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/Lesson_2.iml b/Lesson_2/.idea/Lesson_2.iml
new file mode 100644
index 0000000..74d515a
--- /dev/null
+++ b/Lesson_2/.idea/Lesson_2.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
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/misc.xml b/Lesson_2/.idea/misc.xml
new file mode 100644
index 0000000..c172c48
--- /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..b9acf92
--- /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/main.py b/Lesson_2/main.py
new file mode 100644
index 0000000..94e3a87
--- /dev/null
+++ b/Lesson_2/main.py
@@ -0,0 +1,16 @@
+# This is a sample Python script.
+
+# Press ⌃R to execute it or replace it with your code.
+# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
+
+
+def print_hi(name):
+ # Use a breakpoint in the code line below to debug your script.
+ print(f'Hi, {name}') # Press ⌘F8 to toggle the breakpoint.
+
+
+# Press the green button in the gutter to run the script.
+if __name__ == '__main__':
+ print_hi('PyCharm')
+
+# See PyCharm help at https://www.jetbrains.com/help/pycharm/
diff --git a/Lesson_2/task_5.py b/Lesson_2/task_5.py
new file mode 100644
index 0000000..13632c7
--- /dev/null
+++ b/Lesson_2/task_5.py
@@ -0,0 +1,34 @@
+# Реализовать структуру «Рейтинг», представляющую собой набор натуральных чисел,
+# который не возрастает. У пользователя нужно запрашивать новый элемент рейтинга.
+# Если в рейтинге существуют элементы с одинаковыми значениями, то новый элемент
+# с тем же значением должен разместиться после них.
+# Подсказка. Например, набор натуральных чисел: 7, 5, 3, 3, 2.
+# Пользователь ввёл число 3. Результат: 7, 5, 3, 3, 3, 2.
+# Пользователь ввёл число 8. Результат: 8, 7, 5, 3, 3, 2.
+# Пользователь ввёл число 1. Результат: 7, 5, 3, 3, 2, 1.
+# Набор натуральных чисел можно задать сразу в коде, например, my_list = [7, 5, 3, 3, 2].
+
+num = int(input('Please enter a number: '))
+my_list = [8, 8, 7, 5, 3, 3, 2]
+value = my_list.count(num)
+for el in my_list:
+ if value > 0:
+ i = my_list.index(num)
+ my_list.insert(i + 1, num)
+ # break
+ else:
+ if num > el:
+ j = my_list.index(el)
+ my_list.insert(j, num)
+ # break
+ elif num < my_list[len(my_list) - 1]:
+ my_list.append(num)
+
+ exit = input('Is the value inout complete? (Y/N) ')
+ if exit == 'y' or exit == 'Y':
+ break
+ else:
+ if exit == 'n' or exit == 'N':
+ num = int(input('Please enter a number: '))
+
+print(my_list)
From 4650e4ca0e49c50e04bcf301734896154f43a630 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Thu, 24 Feb 2022 16:36:05 +0300
Subject: [PATCH 20/21] Added some changes.
---
Lesson_2/task_5.py | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/Lesson_2/task_5.py b/Lesson_2/task_5.py
index 13632c7..a88d1df 100644
--- a/Lesson_2/task_5.py
+++ b/Lesson_2/task_5.py
@@ -8,27 +8,21 @@
# Пользователь ввёл число 1. Результат: 7, 5, 3, 3, 2, 1.
# Набор натуральных чисел можно задать сразу в коде, например, my_list = [7, 5, 3, 3, 2].
-num = int(input('Please enter a number: '))
+num = int(input('Please enter a number: ')) #(enter 000 to Exit): '))
my_list = [8, 8, 7, 5, 3, 3, 2]
value = my_list.count(num)
+# while num != 000:
for el in my_list:
if value > 0:
i = my_list.index(num)
my_list.insert(i + 1, num)
- # break
- else:
- if num > el:
- j = my_list.index(el)
- my_list.insert(j, num)
- # break
- elif num < my_list[len(my_list) - 1]:
- my_list.append(num)
-
- exit = input('Is the value inout complete? (Y/N) ')
- if exit == 'y' or exit == 'Y':
break
- else:
- if exit == 'n' or exit == 'N':
- num = int(input('Please enter a number: '))
-
+ elif num > el:
+ j = my_list.index(el)
+ my_list.insert(j, num)
+# break
+ elif num < my_list[len(my_list) - 1]:
+ my_list.append(num)
+# break
print(my_list)
+#num = int(input('Please enter a number: '))
\ No newline at end of file
From 6b6173fc984fa7cedd6e60caa785562779e85fff Mon Sep 17 00:00:00 2001
From: Pavel
Date: Thu, 24 Feb 2022 16:54:40 +0300
Subject: [PATCH 21/21] Added some changes.
---
Lesson_2/task_5.py | 28 +++++++++++-----------------
1 file changed, 11 insertions(+), 17 deletions(-)
diff --git a/Lesson_2/task_5.py b/Lesson_2/task_5.py
index a88d1df..df79fd5 100644
--- a/Lesson_2/task_5.py
+++ b/Lesson_2/task_5.py
@@ -8,21 +8,15 @@
# Пользователь ввёл число 1. Результат: 7, 5, 3, 3, 2, 1.
# Набор натуральных чисел можно задать сразу в коде, например, my_list = [7, 5, 3, 3, 2].
-num = int(input('Please enter a number: ')) #(enter 000 to Exit): '))
-my_list = [8, 8, 7, 5, 3, 3, 2]
-value = my_list.count(num)
-# while num != 000:
-for el in my_list:
- if value > 0:
- i = my_list.index(num)
- my_list.insert(i + 1, num)
- break
- elif num > el:
- j = my_list.index(el)
- my_list.insert(j, num)
-# break
- elif num < my_list[len(my_list) - 1]:
- my_list.append(num)
-# break
+my_list = [8, 8, 7, 5, 3, 3, 2, 1, 1]
print(my_list)
-#num = int(input('Please enter a number: '))
\ No newline at end of file
+num = int(input('Please enter a number (enter 000 to Exit): '))
+while num != 000:
+ i = 0
+ for el in my_list:
+ if num > el:
+ break
+ i += 1
+ my_list.insert(i, num)
+ print(my_list)
+ num = int(input('Please enter a number: '))