From fc049d7a77d8c10d7e63d17a18d665bf2f3a2cfd Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Tue, 31 Aug 2021 11:04:16 +0300 Subject: [PATCH 01/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw1.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Practice/gavrilova/hw1.py diff --git a/Practice/gavrilova/hw1.py b/Practice/gavrilova/hw1.py new file mode 100644 index 0000000..994b2d4 --- /dev/null +++ b/Practice/gavrilova/hw1.py @@ -0,0 +1,26 @@ +def test1(a, b): # вывод на экран большего значения из двух чисел + if a > b: + print(a) + else: + if a < b: + print(b) + else: + return("Числа равны") + +def test2(a, b): # возврат бол7ьшего значения из двух чисел + if a > b: + return(a) + else: + if a < b: + return(b) + else: + print ("Числа равны") + +a = int(input("Введите первое число ")) +b = int(input("Введите второе число ")) + +test1(a,b) +test2(a,b) + +# x = test2(a,b) #проверка возврвщаемого значения +# print x \ No newline at end of file From 0d7744521b31a79d938a8d640d827f68e585cee0 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Tue, 31 Aug 2021 11:13:06 +0300 Subject: [PATCH 02/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw2.py | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Practice/gavrilova/hw2.py diff --git a/Practice/gavrilova/hw2.py b/Practice/gavrilova/hw2.py new file mode 100644 index 0000000..fdc6762 --- /dev/null +++ b/Practice/gavrilova/hw2.py @@ -0,0 +1,41 @@ +class Tank: + + caption = "" + speed = 0 + length = 0 + armament = "" + + def say_caption(self): + print (f"Наименование танка {self.caption}") + + def say_length(self): + print (f"Длина танка {self.length}") + + def say_speed(self): + print (f"Подвижность танка {self.speed}") + + def say_armament(self): + print (f"Вооружение танка {self.armament}") + +t34 = Tank() +t34.caption = "Т34" +t34.length = 5964 +t34.speed = 54 +t34.armament = "76-мм танковая пушка ф-34" + +tiger = Tank() +tiger.caption = "Tiger" +tiger.length = 8450 +tiger.speed = 45 +tiger.armament = "88-мм KwK 36" + +t34.say_caption() +t34.say_length() +t34.say_speed() +t34.say_armament() + + +tiger.say_caption() +tiger.say_length() +tiger.say_speed() +tiger.say_armament() \ No newline at end of file From ccc700c2a33728ac787ef23741c701a97c092a23 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Tue, 31 Aug 2021 11:15:44 +0300 Subject: [PATCH 03/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Practice/gavrilova/hw2.py b/Practice/gavrilova/hw2.py index fdc6762..1d6f137 100644 --- a/Practice/gavrilova/hw2.py +++ b/Practice/gavrilova/hw2.py @@ -1,8 +1,8 @@ class Tank: caption = "" - speed = 0 length = 0 + speed = 0 armament = "" def say_caption(self): From 2e86d2e788b563ce111dab99ab793414c920077c Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Tue, 31 Aug 2021 11:37:55 +0300 Subject: [PATCH 04/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw2.py | 1 + Practice/gavrilova/hw3.py | 27 +++++++++++++++++++++++++++ Practice/gavrilova/hw4.py | 10 ++++++++++ 3 files changed, 38 insertions(+) create mode 100644 Practice/gavrilova/hw3.py create mode 100644 Practice/gavrilova/hw4.py diff --git a/Practice/gavrilova/hw2.py b/Practice/gavrilova/hw2.py index 1d6f137..9747f57 100644 --- a/Practice/gavrilova/hw2.py +++ b/Practice/gavrilova/hw2.py @@ -1,3 +1,4 @@ +#работа с классами class Tank: caption = "" diff --git a/Practice/gavrilova/hw3.py b/Practice/gavrilova/hw3.py new file mode 100644 index 0000000..8741d63 --- /dev/null +++ b/Practice/gavrilova/hw3.py @@ -0,0 +1,27 @@ +def fun(a): + a = a + a + print(a) + + +def get_arg(arg_name): + # While not (arg := input(f'Введите число {arg_name}: ')).isnumeric(): + ## pass + arg = input('Введите число ') + while not arg.isnumeric(): + arg = input('Введите число ') + if arg == "stop" or arg == "Stop" or arg == "STOP" + break + print("Некорректный ввод") + + returm + arg + + +# print(arg) + +# x = None +x = get_arg('x') +fun(x) + +# if x == 'stop': +# print("OK) \ No newline at end of file diff --git a/Practice/gavrilova/hw4.py b/Practice/gavrilova/hw4.py new file mode 100644 index 0000000..d73eed5 --- /dev/null +++ b/Practice/gavrilova/hw4.py @@ -0,0 +1,10 @@ +def check_palindrome(a): + b = a[::-1] + if a == b: + print(a, "Палиндром") + else: + print(a, "Не палиндром") + +x = input("Введите слово: ") +x = x.lower() +check_palindrome(x) \ No newline at end of file From 0a15f1fe6ab693a76bf5da0da9dac4b372ed2bf9 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Tue, 31 Aug 2021 16:00:32 +0300 Subject: [PATCH 05/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw3.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/Practice/gavrilova/hw3.py b/Practice/gavrilova/hw3.py index 8741d63..36085dc 100644 --- a/Practice/gavrilova/hw3.py +++ b/Practice/gavrilova/hw3.py @@ -1,27 +1,30 @@ def fun(a): - a = a + a + y = y.join(a) print(a) -def get_arg(arg_name): - # While not (arg := input(f'Введите число {arg_name}: ')).isnumeric(): - ## pass - arg = input('Введите число ') - while not arg.isnumeric(): +def get_arg(arg): + while not arg.lower() == "stop": arg = input('Введите число ') - if arg == "stop" or arg == "Stop" or arg == "STOP" - break - print("Некорректный ввод") + if arg.isnumeric(): + x.append(arg) - returm - arg + else: + if arg == "stop": +# break + pass +# continue + else: + print("Некорректный ввод") + return x -# print(arg) + # print(arg) -# x = None +y = '' +x = [] x = get_arg('x') -fun(x) +y = y.join(x) +print(y) +#fun(x) -# if x == 'stop': -# print("OK) \ No newline at end of file From 8d4dd3746c39809a176f4541bff823e1ec6d5970 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Tue, 31 Aug 2021 18:14:48 +0300 Subject: [PATCH 06/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw5.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Practice/gavrilova/hw5.py diff --git a/Practice/gavrilova/hw5.py b/Practice/gavrilova/hw5.py new file mode 100644 index 0000000..7cb05be --- /dev/null +++ b/Practice/gavrilova/hw5.py @@ -0,0 +1,22 @@ +import random + +x=0 +number = random.randint(1, 10) + +while True: + x = input("Введите число в диапазоне от 1 до 10:") + + if not x.isnumeric(): + print("Вы ввели не число") + break + + x = int(x) + + if x > number: + print("Загаданное число меньше") + elif x < number: + print("Загаданное число больше") + else: +# x == number: + print("Вы угадали") + break \ No newline at end of file From ed2d42b80f99b05e58e59a7e88471519a5835708 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Fri, 3 Sep 2021 10:22:32 +0300 Subject: [PATCH 07/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw1.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Practice/gavrilova/hw1.py b/Practice/gavrilova/hw1.py index 994b2d4..415a299 100644 --- a/Practice/gavrilova/hw1.py +++ b/Practice/gavrilova/hw1.py @@ -1,26 +1,24 @@ def test1(a, b): # вывод на экран большего значения из двух чисел if a > b: print(a) + elif a < b: + print(b) else: - if a < b: - print(b) - else: - return("Числа равны") + print("Числа равны") def test2(a, b): # возврат бол7ьшего значения из двух чисел if a > b: return(a) + elif a < b: + return(b) else: - if a < b: - return(b) - else: - print ("Числа равны") + return("Числа равны") a = int(input("Введите первое число ")) b = int(input("Введите второе число ")) test1(a,b) -test2(a,b) +#test2(a,b) -# x = test2(a,b) #проверка возврвщаемого значения -# print x \ No newline at end of file +x = test2(a,b) #проверка возврвщаемого значения +print(x) \ No newline at end of file From 393e13076463f0c01e1a34c4c11fb91bd1216bee Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Fri, 3 Sep 2021 10:48:15 +0300 Subject: [PATCH 08/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw3.py | 14 +++++++------- Practice/~$README.md | Bin 0 -> 162 bytes 2 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 Practice/~$README.md diff --git a/Practice/gavrilova/hw3.py b/Practice/gavrilova/hw3.py index 36085dc..fa04bcd 100644 --- a/Practice/gavrilova/hw3.py +++ b/Practice/gavrilova/hw3.py @@ -9,13 +9,13 @@ def get_arg(arg): if arg.isnumeric(): x.append(arg) - else: - if arg == "stop": -# break - pass -# continue - else: - print("Некорректный ввод") + elif arg != "stop": + print("Некорректный ввод") +# else: +# if arg == "stop": +# pass +# else: +# print("Некорректный ввод") return x diff --git a/Practice/~$README.md b/Practice/~$README.md new file mode 100644 index 0000000000000000000000000000000000000000..b79fe514c1c9478ee048abf1f8ba9c2ec804fc34 GIT binary patch literal 162 zcmZQzpa`gM+x@Gafq@ff2qO@K=yPlg3@eUUO%`WjV7U5TWCuuo0q@}^5dX(wr|J`L znHhFn*r0G>%Z1$+`xP!WT-b17JCNLZvE#zl3wtl@0195%bz$Fyy%$?9?7pxA010a^ A1^@s6 literal 0 HcmV?d00001 From 8cb9df2a50de2258d4b5bbe9f6cae96383120530 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Fri, 3 Sep 2021 10:57:26 +0300 Subject: [PATCH 09/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw4.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Practice/gavrilova/hw4.py b/Practice/gavrilova/hw4.py index d73eed5..2facfb3 100644 --- a/Practice/gavrilova/hw4.py +++ b/Practice/gavrilova/hw4.py @@ -1,4 +1,5 @@ def check_palindrome(a): + a = a.lower() b = a[::-1] if a == b: print(a, "Палиндром") @@ -6,5 +7,4 @@ def check_palindrome(a): print(a, "Не палиндром") x = input("Введите слово: ") -x = x.lower() check_palindrome(x) \ No newline at end of file From 18248c5076c09c8b16a7e1b04c34f2936613a7dc Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Fri, 3 Sep 2021 16:33:17 +0300 Subject: [PATCH 10/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw3.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Practice/gavrilova/hw3.py b/Practice/gavrilova/hw3.py index fa04bcd..12e4c6f 100644 --- a/Practice/gavrilova/hw3.py +++ b/Practice/gavrilova/hw3.py @@ -4,6 +4,7 @@ def fun(a): def get_arg(arg): + x = [] while not arg.lower() == "stop": arg = input('Введите число ') if arg.isnumeric(): @@ -22,7 +23,7 @@ def get_arg(arg): # print(arg) y = '' -x = [] +#x = [] x = get_arg('x') y = y.join(x) print(y) From 5a765d48e239625c04a9a27a935774e6db629572 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Fri, 3 Sep 2021 16:40:12 +0300 Subject: [PATCH 11/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Practice/gavrilova/hw1.py b/Practice/gavrilova/hw1.py index 415a299..31661ae 100644 --- a/Practice/gavrilova/hw1.py +++ b/Practice/gavrilova/hw1.py @@ -12,7 +12,7 @@ def test2(a, b): # возврат бол7ьшего значения из дву elif a < b: return(b) else: - return("Числа равны") + return(None) a = int(input("Введите первое число ")) b = int(input("Введите второе число ")) From fe05599d6783bc9002bb39791bb34dee44952a67 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Fri, 3 Sep 2021 16:42:47 +0300 Subject: [PATCH 12/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw1.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Practice/gavrilova/hw1.py b/Practice/gavrilova/hw1.py index 31661ae..eb10377 100644 --- a/Practice/gavrilova/hw1.py +++ b/Practice/gavrilova/hw1.py @@ -8,11 +8,11 @@ def test1(a, b): # вывод на экран большего значения def test2(a, b): # возврат бол7ьшего значения из двух чисел if a > b: - return(a) + return a elif a < b: - return(b) + return b else: - return(None) + return None a = int(input("Введите первое число ")) b = int(input("Введите второе число ")) From f7fefdd47547fdf96723e3133ecec7f80b42cecd Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Tue, 7 Sep 2021 17:01:16 +0300 Subject: [PATCH 13/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw6.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Practice/gavrilova/hw6.py diff --git a/Practice/gavrilova/hw6.py b/Practice/gavrilova/hw6.py new file mode 100644 index 0000000..725f800 --- /dev/null +++ b/Practice/gavrilova/hw6.py @@ -0,0 +1,13 @@ +lst = [] + +for x in range(1, 101): + if x%3 == 0 and x%5 == 0: + lst.append('FizzBuzz') + elif x%3 == 0: + lst.append('Fizz') + elif x%5 == 0: + lst.append('Buzz') + else: + lst.append(x) + +print(lst) \ No newline at end of file From bb4d96b3a867ca0c024e8b731e8545e34c9dadae Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Tue, 7 Sep 2021 17:34:39 +0300 Subject: [PATCH 14/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw7.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Practice/gavrilova/hw7.py diff --git a/Practice/gavrilova/hw7.py b/Practice/gavrilova/hw7.py new file mode 100644 index 0000000..7dc092a --- /dev/null +++ b/Practice/gavrilova/hw7.py @@ -0,0 +1,3 @@ +x = list(input("Введите пятизначное число")) +for i in range(5): + print(f'{i+1} цифра равна {x[i]}') From c496e54045a5bbd3aae000f6474eda3c86098457 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Wed, 8 Sep 2021 11:46:07 +0300 Subject: [PATCH 15/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=208?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw8.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Practice/gavrilova/hw8.py diff --git a/Practice/gavrilova/hw8.py b/Practice/gavrilova/hw8.py new file mode 100644 index 0000000..2a0e28a --- /dev/null +++ b/Practice/gavrilova/hw8.py @@ -0,0 +1,11 @@ +def sort(a): + for i in range(len(a)): + for j in range(len(a)-1-i): + if a[j] < a[j+1]: + a[i], a[j+1] = a[j+1], a[i] + +аrr = list(input("Введите последовательность чисел")) + +print(аrr) +sort(аrr) +print(аrr) \ No newline at end of file From a9a201521aa5ba84de70a21c9c0ef3dc1a59c498 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Wed, 8 Sep 2021 17:52:08 +0300 Subject: [PATCH 16/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=209?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hv9.py | 25 +++++++++++++++++++++++++ Practice/gavrilova/text.txt | 1 + Practice/gavrilova/text_s.txt | 1 + Practice/gavrilova/text_t.txt | 1 + 4 files changed, 28 insertions(+) create mode 100644 Practice/gavrilova/hv9.py create mode 100644 Practice/gavrilova/text.txt create mode 100644 Practice/gavrilova/text_s.txt create mode 100644 Practice/gavrilova/text_t.txt diff --git a/Practice/gavrilova/hv9.py b/Practice/gavrilova/hv9.py new file mode 100644 index 0000000..c8f9c5c --- /dev/null +++ b/Practice/gavrilova/hv9.py @@ -0,0 +1,25 @@ +def fun(f, f_new, before, after): + for line in f: + line_new = line.replace(before, after) + print(line_new) + f_new.write(line_new) + + +with open('text.txt', 'w') as f: + f.write(input('Введите строку ')) + + +while True: + x = input('Для замены пробелов на табуляцию введите t, для замены табуляции на пробелы введите s ') + if x == 't': + with open('text.txt', 'r') as f, \ + open('text_t.txt', 'w') as f_t: + fun(f, f_t, ' ', '\t') + break + elif x == 's': + with open('text.txt', 'r') as f, \ + open('text_s.txt', 'w') as f_s: + fun(f, f_s, '\t', ' ') + break + else: + print('Некорректный ввод') diff --git a/Practice/gavrilova/text.txt b/Practice/gavrilova/text.txt new file mode 100644 index 0000000..5d65bb9 --- /dev/null +++ b/Practice/gavrilova/text.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Practice/gavrilova/text_s.txt b/Practice/gavrilova/text_s.txt new file mode 100644 index 0000000..97afd6a --- /dev/null +++ b/Practice/gavrilova/text_s.txt @@ -0,0 +1 @@ +jkkgkg jljljlkj \ No newline at end of file diff --git a/Practice/gavrilova/text_t.txt b/Practice/gavrilova/text_t.txt new file mode 100644 index 0000000..6f9be9b --- /dev/null +++ b/Practice/gavrilova/text_t.txt @@ -0,0 +1 @@ + \ No newline at end of file From ea3252505d1277653d811bc7c8de55f72eb34e17 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Wed, 8 Sep 2021 18:06:54 +0300 Subject: [PATCH 17/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=209?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw10.py | 0 Practice/gavrilova/{hv9.py => hw9.py} | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Practice/gavrilova/hw10.py rename Practice/gavrilova/{hv9.py => hw9.py} (100%) diff --git a/Practice/gavrilova/hw10.py b/Practice/gavrilova/hw10.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/gavrilova/hv9.py b/Practice/gavrilova/hw9.py similarity index 100% rename from Practice/gavrilova/hv9.py rename to Practice/gavrilova/hw9.py From a02d8e9b7b9848f610d3e78c5c02d17210d2123f Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Wed, 8 Sep 2021 18:22:06 +0300 Subject: [PATCH 18/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=2010?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw10.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Practice/gavrilova/hw10.py b/Practice/gavrilova/hw10.py index e69de29..cfd6d8e 100644 --- a/Practice/gavrilova/hw10.py +++ b/Practice/gavrilova/hw10.py @@ -0,0 +1,8 @@ +dict = {'1': 'красный', '2': 'синий', '3': 'зеленый', '4': 'сиреневый', '5': 'голубой'} + +line = "Камни имеют цвета: рубин 1, сапфир 2, изумруд 3, аметист 4, топаз 5, танзанит 4" + +for i in dict.keys(): + line = line.replace(i, dict[i]) + +print(line) \ No newline at end of file From 29bbeb624e0589f57e1c03251d2e1d915f9dc22d Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Thu, 9 Sep 2021 10:12:05 +0300 Subject: [PATCH 19/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw3.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Practice/gavrilova/hw3.py b/Practice/gavrilova/hw3.py index 12e4c6f..4bf84d9 100644 --- a/Practice/gavrilova/hw3.py +++ b/Practice/gavrilova/hw3.py @@ -22,6 +22,7 @@ def get_arg(arg): # print(arg) +arg = 0 y = '' #x = [] x = get_arg('x') From cf108a48b2af433ad7a4fae5cbe15a3702ee6fd6 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Thu, 9 Sep 2021 10:36:46 +0300 Subject: [PATCH 20/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw6.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Practice/gavrilova/hw6.py b/Practice/gavrilova/hw6.py index 725f800..80787ca 100644 --- a/Practice/gavrilova/hw6.py +++ b/Practice/gavrilova/hw6.py @@ -1,11 +1,11 @@ lst = [] for x in range(1, 101): - if x%3 == 0 and x%5 == 0: + if x % 15 == 0: lst.append('FizzBuzz') - elif x%3 == 0: + elif x % 3 == 0: lst.append('Fizz') - elif x%5 == 0: + elif x % 5 == 0: lst.append('Buzz') else: lst.append(x) From 69d497b9cd287ace43d7f90882bedd4eb0d25e58 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Thu, 9 Sep 2021 10:38:48 +0300 Subject: [PATCH 21/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw7.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Practice/gavrilova/hw7.py b/Practice/gavrilova/hw7.py index 7dc092a..8781849 100644 --- a/Practice/gavrilova/hw7.py +++ b/Practice/gavrilova/hw7.py @@ -1,3 +1,3 @@ -x = list(input("Введите пятизначное число")) -for i in range(5): +x = list(input("Введите число ")) +for i in range(len(x)): print(f'{i+1} цифра равна {x[i]}') From b249606cb2e3765aac6e1cf23ee6895259af0f5a Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Thu, 9 Sep 2021 10:39:55 +0300 Subject: [PATCH 22/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw7.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Practice/gavrilova/hw7.py b/Practice/gavrilova/hw7.py index 8781849..d10a925 100644 --- a/Practice/gavrilova/hw7.py +++ b/Practice/gavrilova/hw7.py @@ -1,3 +1,3 @@ -x = list(input("Введите число ")) +x = input("Введите число ") for i in range(len(x)): print(f'{i+1} цифра равна {x[i]}') From d815b04aa8d846406d0dd4a29e7b2c929b9fded7 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Thu, 9 Sep 2021 12:09:20 +0300 Subject: [PATCH 23/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw8.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Practice/gavrilova/hw8.py b/Practice/gavrilova/hw8.py index 2a0e28a..cb8df1e 100644 --- a/Practice/gavrilova/hw8.py +++ b/Practice/gavrilova/hw8.py @@ -1,10 +1,14 @@ def sort(a): for i in range(len(a)): - for j in range(len(a)-1-i): - if a[j] < a[j+1]: - a[i], a[j+1] = a[j+1], a[i] + n = i +# print("i=",i) + for j in range(i + 1,len(a)): +# print("j=",j) + if a[j] < a[n]: + n = j + a[i], a[n] = a[n], a[i] -аrr = list(input("Введите последовательность чисел")) +аrr = list(input("Введите последовательность чисел ")) print(аrr) sort(аrr) From dbd92f26e4bb71858157efd3a0e91bc430219810 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Wed, 22 Sep 2021 17:45:35 +0300 Subject: [PATCH 24/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=2012?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw12.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Practice/gavrilova/hw12.py diff --git a/Practice/gavrilova/hw12.py b/Practice/gavrilova/hw12.py new file mode 100644 index 0000000..3643b6b --- /dev/null +++ b/Practice/gavrilova/hw12.py @@ -0,0 +1,27 @@ +import time +import random + +class Man: + + def __init__(self, name): + self.name = name + + def solve_task(self): + print("I'm not ready yet") + +class Pupil(Man): + + def __init__(self, name): + self.name = name + + def solve_task(self): + time.sleep(random.randint(3, 6)) + super().solve_task() + +m = Man('Marya') +print(f'Are you ready {m.name}?') +m.solve_task() + +p = Pupil('Evgeniy') +print(f'And you {p.name}?') +p.solve_task() \ No newline at end of file From 35afaeb88c83fe442f1ffbf992acbbc940320b7f Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Wed, 22 Sep 2021 17:48:22 +0300 Subject: [PATCH 25/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=2011?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw11.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Practice/gavrilova/hw11.py diff --git a/Practice/gavrilova/hw11.py b/Practice/gavrilova/hw11.py new file mode 100644 index 0000000..6a12b6a --- /dev/null +++ b/Practice/gavrilova/hw11.py @@ -0,0 +1,27 @@ +import random + +def del_column(lst, x): + for i in range(len(lst)): + for j in reversed(range(len(lst[i]))): + if lst[i][j] == x: + for k in range(len(lst)): + del lst[k][j] + +lst = [ + [1, 1, 2], + [1, 2, 1], + [1, 1, 1] +] + +print(*lst, sep='\n') +x = int(input('Введите число: ')) +del_column(lst, x) +print(*lst, sep='\n') + +row = int(input('Введите кол-во строк: ')) +column = int(input('Введите кол-во столбцов: ')) +lst1 = [[random.randrange(1, 10) for _ in range(column)] for _ in range(row)] +print(*lst1, sep='\n') +x = int(input('Введите число: ')) +del_column(lst1, x) +print(*lst1, sep='\n') \ No newline at end of file From 3b39b99d145bbd08a77859902e34414ab55fff07 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Thu, 23 Sep 2021 11:44:45 +0300 Subject: [PATCH 26/41] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=2013?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/hw13.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Practice/gavrilova/hw13.py diff --git a/Practice/gavrilova/hw13.py b/Practice/gavrilova/hw13.py new file mode 100644 index 0000000..8b22879 --- /dev/null +++ b/Practice/gavrilova/hw13.py @@ -0,0 +1,37 @@ +import tempfile +import os + +class WrapStrToFile: + + def __init__(self): + self.filepath = tempfile.mktemp(suffix='.txt', dir='.') + + @property + def content(self): + try: + with open(self.filepath, 'r') as f: + data = f.read() + except Exception: + data = "Файл еще не существует" + return data + + @content.setter + def content(self, value): + with open(self.filepath, 'w') as f: + f.write(str(value)) + + @content.deleter + def content(self): + print('Файл удален') +# os.close(fd) + os.unlink(self.filepath) + + +wstf = WrapStrToFile() +print(wstf.filepath) +print(wstf.content) +wstf.content = 'Привет' +print(wstf.content) +wstf.content = 'Привет еще раз' +print(wstf.content) +del wstf.content \ No newline at end of file From abba903fdf19feaf989f6bb280ce5b3fd166f97c Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Fri, 24 Sep 2021 18:27:35 +0300 Subject: [PATCH 27/41] =?UTF-8?q?=D1=8D=D0=BA=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/1.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Practice/gavrilova/1.py diff --git a/Practice/gavrilova/1.py b/Practice/gavrilova/1.py new file mode 100644 index 0000000..6e16cda --- /dev/null +++ b/Practice/gavrilova/1.py @@ -0,0 +1,7 @@ +def fun(a): + a = len(a) + return a + +list = [123, 'abc', 'apple'] +x = fun(list) +print (x) \ No newline at end of file From 10cc86d2f103cdfecc795b1bc7d54f44f4fa8e00 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Fri, 24 Sep 2021 18:28:00 +0300 Subject: [PATCH 28/41] =?UTF-8?q?=D1=8D=D0=BA=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/2.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Practice/gavrilova/2.py diff --git a/Practice/gavrilova/2.py b/Practice/gavrilova/2.py new file mode 100644 index 0000000..f7de3a6 --- /dev/null +++ b/Practice/gavrilova/2.py @@ -0,0 +1,7 @@ +def reversed(a): + a = list[::-1] + return a + +list = [123, 'abc', 'apple'] +x = reversed(list) +print (x) \ No newline at end of file From ffaf7f0b18c9f139899341ae66029eaa50a12b94 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Fri, 24 Sep 2021 18:28:16 +0300 Subject: [PATCH 29/41] =?UTF-8?q?=D1=8D=D0=BA=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/4.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Practice/gavrilova/4.py diff --git a/Practice/gavrilova/4.py b/Practice/gavrilova/4.py new file mode 100644 index 0000000..72d5223 --- /dev/null +++ b/Practice/gavrilova/4.py @@ -0,0 +1,11 @@ +def to_title(a): +# return a.title() + t = a.split(' ') + for i in range(1, len(t)): + t[i] = t[i][0].upper() + t[i][1:] + return ' '.join(t) + +s = 'orlov Ilya evgenyevich' +print (s) +s1 = to_title(s).capitalize() +print (s1) From 205b3caf88adc59c37447ffa1280dd4f232497c7 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Fri, 24 Sep 2021 18:28:29 +0300 Subject: [PATCH 30/41] =?UTF-8?q?=D1=8D=D0=BA=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/5.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Practice/gavrilova/5.py diff --git a/Practice/gavrilova/5.py b/Practice/gavrilova/5.py new file mode 100644 index 0000000..5318d3a --- /dev/null +++ b/Practice/gavrilova/5.py @@ -0,0 +1,7 @@ +def count_symbol(a): + counter = a.count('i') + return counter + +s = 'Hi, Elvis, I am here!' +s1 = count_symbol(s) +print ('Символ i встречается в строке: ' + s + ' '+str(s1)+' раза') From 0c4d6e5c145cce47e8494827c838df498f6a739c Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Fri, 24 Sep 2021 18:29:09 +0300 Subject: [PATCH 31/41] =?UTF-8?q?=D1=8D=D0=BA=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/7-1.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Practice/gavrilova/7-1.py diff --git a/Practice/gavrilova/7-1.py b/Practice/gavrilova/7-1.py new file mode 100644 index 0000000..bdc3749 --- /dev/null +++ b/Practice/gavrilova/7-1.py @@ -0,0 +1,20 @@ +f1 = 'sourse.txt' +f2 = 'destination.txt' +try: + file1 = open('sourse.txt', 'r') + textfile1 = file1.read() +except Exception: + print("Файл " + f1 + " не найден") +else: + try: + file2 = open('destination.txt', 'w') + file2.write(textfile1) + except Exception: + print("Файл " + f2 + " используется") + print(textfile1) + file1.close() + file2.close() + file2 = open('destination.txt', 'r') + textfile2 = file2.read() + print(textfile2) + file2.close() \ No newline at end of file From 71e8ae84f41be5e3e408a3fd350cb78538a9fcb0 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Fri, 24 Sep 2021 18:29:38 +0300 Subject: [PATCH 32/41] =?UTF-8?q?=D1=8D=D0=BA=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=209?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/9.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Practice/gavrilova/9.py diff --git a/Practice/gavrilova/9.py b/Practice/gavrilova/9.py new file mode 100644 index 0000000..33d2521 --- /dev/null +++ b/Practice/gavrilova/9.py @@ -0,0 +1,33 @@ +class User: + def __init__(self,name, age): + self.name = name + self.age = age + + def setName(self): + pass + + def getName(self, name): + pass + + def setAge(self): + pass + + def getAge(self, name): + pass + +class Worker(User): + def __init__(self, name, age, salary): + super(Worker, self).__init__(name, age) + self.salary = salary + + def setSalary(self): + pass + + def getSalary(self, name): + pass + +w1 = Worker("John", 25, 1000) +print(w1.salary) +w2 = Worker("Jack", 26, 2000) +print(w2.salary) +print (w1.salary+w2.salary) \ No newline at end of file From 1484c822afb4de6337ca229fe2f5d749de768c33 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Fri, 24 Sep 2021 18:33:41 +0300 Subject: [PATCH 33/41] =?UTF-8?q?=D1=8D=D0=BA=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/5.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Practice/gavrilova/5.py b/Practice/gavrilova/5.py index 5318d3a..9c6cae9 100644 --- a/Practice/gavrilova/5.py +++ b/Practice/gavrilova/5.py @@ -4,4 +4,4 @@ def count_symbol(a): s = 'Hi, Elvis, I am here!' s1 = count_symbol(s) -print ('Символ i встречается в строке: ' + s + ' '+str(s1)+' раза') +print ('Символ i встречается в строке: ' + s + ' '+str(s1)+' раз') From 63422fbfb86111143d66a8f8b28151b73269e873 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Mon, 27 Sep 2021 11:52:52 +0300 Subject: [PATCH 34/41] =?UTF-8?q?=D1=8D=D0=BA=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/1.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Practice/gavrilova/1.py b/Practice/gavrilova/1.py index 6e16cda..a9273bb 100644 --- a/Practice/gavrilova/1.py +++ b/Practice/gavrilova/1.py @@ -1,7 +1,10 @@ -def fun(a): - a = len(a) - return a +def length(lst): + if not lst: + return 0 + return 1 + length(lst[1:]) + + +a = [1, 2, 3] +l = length(a) +print("Длина списка равна: " + str(l)) -list = [123, 'abc', 'apple'] -x = fun(list) -print (x) \ No newline at end of file From 091d391d0cfb610306a4b80230448b44c9af5307 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Mon, 27 Sep 2021 12:06:02 +0300 Subject: [PATCH 35/41] =?UTF-8?q?=D1=8D=D0=BA=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/2.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Practice/gavrilova/2.py b/Practice/gavrilova/2.py index f7de3a6..54a75b4 100644 --- a/Practice/gavrilova/2.py +++ b/Practice/gavrilova/2.py @@ -1,7 +1,6 @@ -def reversed(a): - a = list[::-1] - return a +def myreversed(a): + return list[::-1] list = [123, 'abc', 'apple'] -x = reversed(list) +x = myreversed(list) print (x) \ No newline at end of file From ef7194613ac77c687536132562b636aef56d1564 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Mon, 27 Sep 2021 12:32:53 +0300 Subject: [PATCH 36/41] =?UTF-8?q?=D1=8D=D0=BA=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/5.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Practice/gavrilova/5.py b/Practice/gavrilova/5.py index 9c6cae9..ca3bc7b 100644 --- a/Practice/gavrilova/5.py +++ b/Practice/gavrilova/5.py @@ -1,7 +1,10 @@ def count_symbol(a): - counter = a.count('i') - return counter + count = 0 + for i in test_str: + if i == 'i': + count = count + 1 + return count -s = 'Hi, Elvis, I am here!' -s1 = count_symbol(s) -print ('Символ i встречается в строке: ' + s + ' '+str(s1)+' раз') +test_str = 'Hi, Elvis, I am here!' +n = count_symbol(test_str) +print ('Символ i встречается в строке: ' + test_str + ' '+str(n)+' раз') From 8da7a1b8327cc3d67ce54e8ffc7a4ff71d8c4865 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Mon, 27 Sep 2021 12:57:20 +0300 Subject: [PATCH 37/41] =?UTF-8?q?=D1=8D=D0=BA=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/5.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Practice/gavrilova/5.py b/Practice/gavrilova/5.py index ca3bc7b..e7cf981 100644 --- a/Practice/gavrilova/5.py +++ b/Practice/gavrilova/5.py @@ -1,10 +1,11 @@ -def count_symbol(a): +def count_symbol(a, s): count = 0 - for i in test_str: - if i == 'i': + for i in a: + if i == s: count = count + 1 return count test_str = 'Hi, Elvis, I am here!' -n = count_symbol(test_str) -print ('Символ i встречается в строке: ' + test_str + ' '+str(n)+' раз') +simv = 'i' +n = count_symbol(test_str, simv) +print ('Символ ' + simv + ' встречается в строке: ' + test_str + ' '+str(n)+' раз') From e18ac04f6c86bd1257caa6be8fd27483af0f0432 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Mon, 27 Sep 2021 16:10:42 +0300 Subject: [PATCH 38/41] =?UTF-8?q?=D1=8D=D0=BA=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/7-1.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Practice/gavrilova/7-1.py b/Practice/gavrilova/7-1.py index bdc3749..7d180bb 100644 --- a/Practice/gavrilova/7-1.py +++ b/Practice/gavrilova/7-1.py @@ -1,20 +1,26 @@ f1 = 'sourse.txt' f2 = 'destination.txt' try: - file1 = open('sourse.txt', 'r') - textfile1 = file1.read() + with open(f1, 'r') as file1: +# file1 = open(f1, 'r') + textfile1 = file1.read() except Exception: - print("Файл " + f1 + " не найден") + print(f'Файл {f1} не найден') +# print("Файл " + f1 + " не найден") else: try: - file2 = open('destination.txt', 'w') - file2.write(textfile1) + with open(f2, 'r') as file2: + print(f'Файл {f2} уже существует') +# file2 = open(f2, 'w') +# file2.write(textfile1) except Exception: - print("Файл " + f2 + " используется") + with open(f2, 'w') as file2: + file2.write(textfile1) print(textfile1) - file1.close() - file2.close() - file2 = open('destination.txt', 'r') - textfile2 = file2.read() - print(textfile2) - file2.close() \ No newline at end of file +# file1.close() +# file2.close() + with open(f2, 'r') as file2: +# file2 = open(f2, 'r') + textfile2 = file2.read() + print(textfile2) +# file2.close() \ No newline at end of file From d163b1081738f2cc1a814b095d9c64ef2b64f495 Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Mon, 27 Sep 2021 16:44:20 +0300 Subject: [PATCH 39/41] =?UTF-8?q?=D1=8D=D0=BA=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/5.py | 5 +++-- Practice/gavrilova/9.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Practice/gavrilova/5.py b/Practice/gavrilova/5.py index e7cf981..f8213eb 100644 --- a/Practice/gavrilova/5.py +++ b/Practice/gavrilova/5.py @@ -2,10 +2,11 @@ def count_symbol(a, s): count = 0 for i in a: if i == s: - count = count + 1 + count += 1 return count test_str = 'Hi, Elvis, I am here!' simv = 'i' n = count_symbol(test_str, simv) -print ('Символ ' + simv + ' встречается в строке: ' + test_str + ' '+str(n)+' раз') +print(f'Символ {simv} встречается в строке: {test_str} {str(n)} раза') +#print ('Символ ' + simv + ' встречается в строке: ' + test_str + ' '+str(n)+' раз') diff --git a/Practice/gavrilova/9.py b/Practice/gavrilova/9.py index 33d2521..cb25ca8 100644 --- a/Practice/gavrilova/9.py +++ b/Practice/gavrilova/9.py @@ -6,13 +6,13 @@ def __init__(self,name, age): def setName(self): pass - def getName(self, name): + def getName(self): pass def setAge(self): pass - def getAge(self, name): + def getAge(self): pass class Worker(User): @@ -23,7 +23,7 @@ def __init__(self, name, age, salary): def setSalary(self): pass - def getSalary(self, name): + def getSalary(self): pass w1 = Worker("John", 25, 1000) From 82ff4a9b0afcdbbe658e20558aca20445299dbde Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Mon, 27 Sep 2021 16:45:45 +0300 Subject: [PATCH 40/41] =?UTF-8?q?=D1=8D=D0=BA=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/5.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Practice/gavrilova/5.py b/Practice/gavrilova/5.py index f8213eb..73d4df8 100644 --- a/Practice/gavrilova/5.py +++ b/Practice/gavrilova/5.py @@ -8,5 +8,5 @@ def count_symbol(a, s): test_str = 'Hi, Elvis, I am here!' simv = 'i' n = count_symbol(test_str, simv) -print(f'Символ {simv} встречается в строке: {test_str} {str(n)} раза') +print(f'Символ {simv} встречается в строке {test_str} {str(n)} раза') #print ('Символ ' + simv + ' встречается в строке: ' + test_str + ' '+str(n)+' раз') From 824e4669690aabe7b7ee4c963857ac51cf5e966b Mon Sep 17 00:00:00 2001 From: "m.gavrilova" Date: Tue, 28 Sep 2021 18:44:23 +0300 Subject: [PATCH 41/41] =?UTF-8?q?=D1=8D=D0=BA=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=209?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/gavrilova/9.py | 65 ++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/Practice/gavrilova/9.py b/Practice/gavrilova/9.py index cb25ca8..9f8107f 100644 --- a/Practice/gavrilova/9.py +++ b/Practice/gavrilova/9.py @@ -1,33 +1,56 @@ class User: - def __init__(self,name, age): - self.name = name - self.age = age - def setName(self): - pass + name = ' ' + age = 0 +# def __init__(self, name, age): +# self.name = name +# self.age = age + + def setName(self, name): + self.name = name def getName(self): - pass + return self.name - def setAge(self): - pass + def setAge(self, age): + self.age = age def getAge(self): - pass + return self.age + class Worker(User): - def __init__(self, name, age, salary): - super(Worker, self).__init__(name, age) - self.salary = salary - def setSalary(self): - pass + salary = 0 +# def __init__(self, name, age, salary): +# super(Worker, self).__init__(name, age) +# self.salary = salary - def getSalary(self): - pass + def setSalary(self, salary): + self.salary = salary -w1 = Worker("John", 25, 1000) -print(w1.salary) -w2 = Worker("Jack", 26, 2000) -print(w2.salary) -print (w1.salary+w2.salary) \ No newline at end of file + def getSalary(self): + return self.salary + + +w1 = Worker() +w1.setName('John') +print(w1.getName()) +w1.setAge(25) +print(w1.getAge()) +w1.setSalary(1000) +print(w1.getSalary()) +w2 = Worker() +w2.setName('Jack') +print(w2.getName()) +w2.setAge(26) +print(w2.getAge()) +w2.setSalary(2000) +print(w2.getSalary()) +s = w1.getSalary() + w2.getSalary() +print(f'Сумма зарплат объектов John и Jack {s} ') +#w1 = Worker("John", 25, 1000) +#print(w1.salary) +#w2 = Worker("Jack", 26, 2000) +#print(w2.salary) +#print (w1.salary+w2.salary) \ No newline at end of file