From 4a1e10760940bddac1a3abbaf4a5e3a201275334 Mon Sep 17 00:00:00 2001 From: AvokrichA <93881730+AvokrichA@users.noreply.github.com> Date: Sun, 7 Nov 2021 22:43:29 +0300 Subject: [PATCH 01/29] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 42e11cd..4193ef4 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# Pyton \ No newline at end of file +# Python From e886a281251c6a2855b71f550c51a6efc211ab4b Mon Sep 17 00:00:00 2001 From: AvokrichA <93881730+AvokrichA@users.noreply.github.com> Date: Fri, 12 Nov 2021 19:16:15 +0300 Subject: [PATCH 02/29] Add files via upload --- lesson2_task_all.py | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 lesson2_task_all.py diff --git a/lesson2_task_all.py b/lesson2_task_all.py new file mode 100644 index 0000000..6365ba6 --- /dev/null +++ b/lesson2_task_all.py @@ -0,0 +1,54 @@ + +#ЗАДАНИЕ1 +# list_1=(1,1.3,'fine',False, {'price', 224, True}, [1,3,5,5.5,8,0.5,'oro']) +# for all_type in list_1: +# print(type(all_type)) + +#ЗАДАНИЕ2 (не работает как надо, не знаю почему) +# list1 = input("Перечислите не менее 5 наименований:").split() +# your_list = len(list1) +# i=0 +# if your_list > 1: +# while i < your_list - 1: +# your_list[i], your_list[i+ 1] = your_list[i + 1], your_list[i] +# i += 2 +# +# print(your_list) + +#ЗАДАНИЕ3 +# month=input("Введите число месяца от 1 до 12:") +# win = 'зима' +# spr = 'весна' +# sum = 'лето' +# aut = 'осень' +# dict_season= {'1':win , '2':win, '3':spr, '4':spr, '5':spr, '6':sum, '7':sum, '8':sum, '9':aut, '10':aut, '11':aut, '12':win} +# print(dict_season[month]) +# +# month_list=[win, win, spr, spr, spr, sum, sum, sum, aut, aut, aut, win,win] +# print(month_list[int(month)]) + +#ЗАДАНИЕ4 +# name_user= (input('Введите ФИО полностью:')).split() +# for a, b in enumerate(name_user): +# print(f'{a} - {b[:10]}') + +#ЗАДАНИЕ5 +rating = [7, 5, 3, 3, 2] +user_rating = int(input('Оцените работу оператора от 1 до 10:')) +answer = False +for index, elem in enumerate(rating): + if user_rating > elem: + rating.insert(index, user_rating) + answer = True + break + +if not answer: + rating.append(user_rating) + +print(rating) + + + + + + From 6b861dbcc0f509da448b5da22dccce9dd5d3c0d6 Mon Sep 17 00:00:00 2001 From: AvokrichA Date: Sat, 13 Nov 2021 16:42:50 +0300 Subject: [PATCH 03/29] add folder Lesson_2 --- .idea/.gitignore | 3 +++ .idea/Pyton.git.iml | 8 ++++++++ .idea/inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/misc.xml | 4 ++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 7 +++++++ HomeTask1.zip | Bin 0 -> 1042 bytes New/.idea/.gitignore | 3 +++ New/.idea/vcs.xml | 6 ++++++ New/archive/lesson2_1.py | 4 ++++ 10 files changed, 49 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/Pyton.git.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 HomeTask1.zip create mode 100644 New/.idea/.gitignore create mode 100644 New/.idea/vcs.xml create mode 100644 New/archive/lesson2_1.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/Pyton.git.iml b/.idea/Pyton.git.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/Pyton.git.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d56657a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..6bf975f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..d5bcecf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/HomeTask1.zip b/HomeTask1.zip new file mode 100644 index 0000000000000000000000000000000000000000..192d1f0b3f1bf37e5848797e2d7caffa90211c75 GIT binary patch literal 1042 zcmWIWW@Zs#U|`^2aO=$o7V2quSi;P}aFd;Zfd?q+k)N9yl31K=s8>)~8k*~O+d<%O z{}I_`ZX7{Oo?hKoRxEROZ0Om*!gtDjwN{siP{;}o*Y2pT^%`rd7}Zq{stBwzs9wA; zGCxP1_vZ%N&70rvoq01>{{#QOL-#-Ie>DHk+@jCL+*2n7-}$tSUv|^UuYFpnQQLk* zUEO&+wseiun_~B^1@8}LMQZw3YVC@vw4Ajf_BZSKn?m72&n8(j9d7hduX`YPpLw}o z(r1Bwb(^N!{s)eEY|KC3b>h;JzMm6oW0>U*m=cdys<`2A~-tQdRIvTT-4!?`m zRyDn&AF|}=jF~6bZ+%qxqjKVk!!w!U)V7`M3!bBOQ#9%$ z$2a3Ge7WyBIo`e0dv&}{Bd|-$I>9OD-ioclAG&wGsjuPGo_z7~`|o#|)nDE}^K9wq zA3Lf&?RArUFQ`>k-Kbf{c{bosrhm|}+RtgzUWmrHKA-zIRHiz~Hu2+~$FGH_z23QM zwb~^4f`qcmyss{ry57*8a%$;vHTI78r!F3>jhtlUs;%{AXX2u-p6Ce5*cP3nq zUb*5F_Y;{TA!ROG4W9kt>WX&i%MDq!&^%6kt-q(xk8N_#+y&T$l$J=@G48fp`(M1F zO({O%i`1NJz0EI!_|(3sZwSp!bE?$NU2!R8t>FK*73{oM`=)P^$y}A{^!U{B9+Tw- zB?ddS{(WNL_`7oNYJM3(tLFSTvZSW>SfHK%-upFsR{bIxgw9!VX=kJH-coV=tX z7_Yv$H{i<71Fwz$M(oOq3w;=Q|El%3v~5Q5*2mv_G{l{F^C#$5$IP99X3w5)J2~xg zIlH+`u3laRfBWxBY40L--PRl%`{O5~^tQxAT`WvATX(E)|9^%6Z$>7223+}51(-uY zKmkmm=2kAKC?kUegW{#9=ht1i&ZueaeR%_rwo*8|T^L9Qc(byBv@!x=9FU#|%=ruq E0GuJ%m;e9( literal 0 HcmV?d00001 diff --git a/New/.idea/.gitignore b/New/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/New/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/New/.idea/vcs.xml b/New/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/New/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/New/archive/lesson2_1.py b/New/archive/lesson2_1.py new file mode 100644 index 0000000..6c0cfd6 --- /dev/null +++ b/New/archive/lesson2_1.py @@ -0,0 +1,4 @@ +ЗАДАНИЕ1 +list_1=(1,1.3,'fine',False, {'price', 224, True}, [1,3,5,5.5,8,0.5,'oro']) +for all_type in list_1: + print(type(all_type)) From c6d4b1fbf026974bdc0bacdc72b99465737efd95 Mon Sep 17 00:00:00 2001 From: AvokrichA Date: Sat, 13 Nov 2021 16:47:34 +0300 Subject: [PATCH 04/29] testing --- Lesson_3/Les3Task1.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Lesson_3/Les3Task1.py diff --git a/Lesson_3/Les3Task1.py b/Lesson_3/Les3Task1.py new file mode 100644 index 0000000..61440ec --- /dev/null +++ b/Lesson_3/Les3Task1.py @@ -0,0 +1,3 @@ +list_1=(1,1.3,'fine',False, {'price', 224, True}, [1,3,5,5.5,8,0.5,'oro']) +for all_type in list_1: +# print(type(all_type)) \ No newline at end of file From 5e7f5c43cbfae6a588412690b419a6c7b6a2f7e2 Mon Sep 17 00:00:00 2001 From: AvokrichA Date: Sat, 13 Nov 2021 17:00:01 +0300 Subject: [PATCH 05/29] testing --- Lesson2/Les2Task1.py | 3 +++ Lesson2_/Les2Task1.py | 4 ++++ Lesson2_/Les2Task2.py | 10 ++++++++++ Lesson2_/Les2Task3.py | 11 +++++++++++ Lesson2_/Les2Task4.py | 4 ++++ Lesson2_/Les2Task5.py | 14 ++++++++++++++ 6 files changed, 46 insertions(+) create mode 100644 Lesson2/Les2Task1.py create mode 100644 Lesson2_/Les2Task1.py create mode 100644 Lesson2_/Les2Task2.py create mode 100644 Lesson2_/Les2Task3.py create mode 100644 Lesson2_/Les2Task4.py create mode 100644 Lesson2_/Les2Task5.py diff --git a/Lesson2/Les2Task1.py b/Lesson2/Les2Task1.py new file mode 100644 index 0000000..d7b76e9 --- /dev/null +++ b/Lesson2/Les2Task1.py @@ -0,0 +1,3 @@ +list_1=(1,1.3,'fine',False, {'price', 224, True}, [1,3,5,5.5,8,0.5,'oro']) +for all_type in list_1: + print(type(all_type)) \ No newline at end of file diff --git a/Lesson2_/Les2Task1.py b/Lesson2_/Les2Task1.py new file mode 100644 index 0000000..1e314b6 --- /dev/null +++ b/Lesson2_/Les2Task1.py @@ -0,0 +1,4 @@ +list_1=(1,1.3,'fine',False, {'price', 224, True}, [1,3,5,5.5,8,0.5,'oro']) +for all_type in list_1: + print(type(all_type)) + # testing \ No newline at end of file diff --git a/Lesson2_/Les2Task2.py b/Lesson2_/Les2Task2.py new file mode 100644 index 0000000..45db405 --- /dev/null +++ b/Lesson2_/Les2Task2.py @@ -0,0 +1,10 @@ +list1 = input("Перечислите не менее 5 наименований:").split() +your_list = len(list1) +i=0 +if your_list > 1: + while i < your_list - 1: + your_list[i], your_list[i+ 1] = your_list[i + 1], your_list[i] + i += 2 + +print(your_list) +# testing \ No newline at end of file diff --git a/Lesson2_/Les2Task3.py b/Lesson2_/Les2Task3.py new file mode 100644 index 0000000..05096ab --- /dev/null +++ b/Lesson2_/Les2Task3.py @@ -0,0 +1,11 @@ +month=input("Введите число месяца от 1 до 12:") +win = 'зима' +spr = 'весна' +sum = 'лето' +aut = 'осень' +dict_season= {'1':win , '2':win, '3':spr, '4':spr, '5':spr, '6':sum, '7':sum, '8':sum, '9':aut, '10':aut, '11':aut, '12':win} +print(dict_season[month]) + +month_list=[win, win, spr, spr, spr, sum, sum, sum, aut, aut, aut, win,win] +print(month_list[int(month)]) +# testing \ No newline at end of file diff --git a/Lesson2_/Les2Task4.py b/Lesson2_/Les2Task4.py new file mode 100644 index 0000000..657ae16 --- /dev/null +++ b/Lesson2_/Les2Task4.py @@ -0,0 +1,4 @@ +name_user= (input('Введите ФИО полностью:')).split() +for a, b in enumerate(name_user): + print(f'{a} - {b[:10]}') + # testing \ No newline at end of file diff --git a/Lesson2_/Les2Task5.py b/Lesson2_/Les2Task5.py new file mode 100644 index 0000000..19c0203 --- /dev/null +++ b/Lesson2_/Les2Task5.py @@ -0,0 +1,14 @@ +rating = [7, 5, 3, 3, 2] +user_rating = int(input('Оцените работу оператора от 1 до 10:')) +answer = False +for index, elem in enumerate(rating): + if user_rating > elem: + rating.insert(index, user_rating) + answer = True + break + +if not answer: + rating.append(user_rating) + +print(rating) +# testing \ No newline at end of file From 4ff0271d4fea9046a165607417c981902c0d631d Mon Sep 17 00:00:00 2001 From: AvokrichA Date: Sat, 13 Nov 2021 17:00:54 +0300 Subject: [PATCH 06/29] testing --- Lesson2/Les2Task1.py | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 Lesson2/Les2Task1.py diff --git a/Lesson2/Les2Task1.py b/Lesson2/Les2Task1.py deleted file mode 100644 index d7b76e9..0000000 --- a/Lesson2/Les2Task1.py +++ /dev/null @@ -1,3 +0,0 @@ -list_1=(1,1.3,'fine',False, {'price', 224, True}, [1,3,5,5.5,8,0.5,'oro']) -for all_type in list_1: - print(type(all_type)) \ No newline at end of file From c6694467a9fd8894ad56bb41d699061917de1a4f Mon Sep 17 00:00:00 2001 From: AvokrichA Date: Sat, 13 Nov 2021 17:32:57 +0300 Subject: [PATCH 07/29] testing --- Lesson2_/Les2Task5.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lesson2_/Les2Task5.py b/Lesson2_/Les2Task5.py index 19c0203..40c975c 100644 --- a/Lesson2_/Les2Task5.py +++ b/Lesson2_/Les2Task5.py @@ -11,4 +11,3 @@ rating.append(user_rating) print(rating) -# testing \ No newline at end of file From 1e342bdffdb46b4a5de44d5e8f6ae19bdb123ebc Mon Sep 17 00:00:00 2001 From: AvokrichA Date: Sun, 14 Nov 2021 00:00:01 +0300 Subject: [PATCH 08/29] create test file --- Lesson2_/test.py | 2 ++ Lesson_3/Les3Task1.py | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) create mode 100644 Lesson2_/test.py diff --git a/Lesson2_/test.py b/Lesson2_/test.py new file mode 100644 index 0000000..51861ad --- /dev/null +++ b/Lesson2_/test.py @@ -0,0 +1,2 @@ +a = 10 +print(a) \ No newline at end of file diff --git a/Lesson_3/Les3Task1.py b/Lesson_3/Les3Task1.py index 61440ec..e69de29 100644 --- a/Lesson_3/Les3Task1.py +++ b/Lesson_3/Les3Task1.py @@ -1,3 +0,0 @@ -list_1=(1,1.3,'fine',False, {'price', 224, True}, [1,3,5,5.5,8,0.5,'oro']) -for all_type in list_1: -# print(type(all_type)) \ No newline at end of file From 05982bc150cd017e29200f300f23b1742b5b3612 Mon Sep 17 00:00:00 2001 From: AvokrichA Date: Sun, 14 Nov 2021 00:09:27 +0300 Subject: [PATCH 09/29] create files --- Lesson_3/Les3Task1.py | 2 ++ Lesson_4/Les4_Task1.py | 2 ++ Lesson_4/Les4_Task2.py | 2 ++ 3 files changed, 6 insertions(+) create mode 100644 Lesson_4/Les4_Task1.py create mode 100644 Lesson_4/Les4_Task2.py diff --git a/Lesson_3/Les3Task1.py b/Lesson_3/Les3Task1.py index e69de29..33ba2d9 100644 --- a/Lesson_3/Les3Task1.py +++ b/Lesson_3/Les3Task1.py @@ -0,0 +1,2 @@ +a=10 +print(a) diff --git a/Lesson_4/Les4_Task1.py b/Lesson_4/Les4_Task1.py new file mode 100644 index 0000000..36f001d --- /dev/null +++ b/Lesson_4/Les4_Task1.py @@ -0,0 +1,2 @@ +a=10 +print(a) \ No newline at end of file diff --git a/Lesson_4/Les4_Task2.py b/Lesson_4/Les4_Task2.py new file mode 100644 index 0000000..36f001d --- /dev/null +++ b/Lesson_4/Les4_Task2.py @@ -0,0 +1,2 @@ +a=10 +print(a) \ No newline at end of file From 7c2e87d40df09784f715a3a8c540533dfc56199a Mon Sep 17 00:00:00 2001 From: AvokrichA Date: Sun, 14 Nov 2021 00:09:58 +0300 Subject: [PATCH 10/29] b = 20 --- Lesson_3/Les3Task1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lesson_3/Les3Task1.py b/Lesson_3/Les3Task1.py index 33ba2d9..69923b1 100644 --- a/Lesson_3/Les3Task1.py +++ b/Lesson_3/Les3Task1.py @@ -1,2 +1,3 @@ a=10 print(a) +b=20 From 4bd66129830f37cb69ff207932f268cc971809c7 Mon Sep 17 00:00:00 2001 From: AvokrichA Date: Sun, 14 Nov 2021 00:22:30 +0300 Subject: [PATCH 11/29] b = 20 --- Lesson_3/Les3Task1.py | 1 + Lesson_3/Les3Task2.py | 1 + 2 files changed, 2 insertions(+) create mode 100644 Lesson_3/Les3Task2.py diff --git a/Lesson_3/Les3Task1.py b/Lesson_3/Les3Task1.py index 69923b1..4e9f381 100644 --- a/Lesson_3/Les3Task1.py +++ b/Lesson_3/Les3Task1.py @@ -1,3 +1,4 @@ a=10 print(a) b=20 +c=30 \ No newline at end of file diff --git a/Lesson_3/Les3Task2.py b/Lesson_3/Les3Task2.py new file mode 100644 index 0000000..67c3fdf --- /dev/null +++ b/Lesson_3/Les3Task2.py @@ -0,0 +1 @@ +a=2 From 1336db0dae8128676e4585f93e88f783a681a5c9 Mon Sep 17 00:00:00 2001 From: AvokrichA Date: Sun, 14 Nov 2021 00:26:53 +0300 Subject: [PATCH 12/29] a b c --- Lesson_3/Les3Task2.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lesson_3/Les3Task2.py b/Lesson_3/Les3Task2.py index 67c3fdf..9d15d98 100644 --- a/Lesson_3/Les3Task2.py +++ b/Lesson_3/Les3Task2.py @@ -1 +1,3 @@ a=2 +b=3 +c=4 \ No newline at end of file From 75c9af76d9ef97096421f5424242fc9d55015596 Mon Sep 17 00:00:00 2001 From: AvokrichA Date: Sun, 14 Nov 2021 11:33:57 +0300 Subject: [PATCH 13/29] =?UTF-8?q?=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D0=B01?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lesson_3/Les3Task1.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Lesson_3/Les3Task1.py b/Lesson_3/Les3Task1.py index 4e9f381..075f1f1 100644 --- a/Lesson_3/Les3Task1.py +++ b/Lesson_3/Les3Task1.py @@ -1,4 +1,14 @@ -a=10 -print(a) -b=20 -c=30 \ No newline at end of file + +def num_list_div(x, y): + if y==0: + return "На 0 делить нельзя!" + else: + return x / y + +x=float(input('Введите делимое:')) +y=float(input('Введите делитель:')) + +print(num_list_div(x, y)) + + + From f9efe5d2e5af598f96f048855eebd788ac9a6589 Mon Sep 17 00:00:00 2001 From: AvokrichA Date: Sun, 14 Nov 2021 12:18:15 +0300 Subject: [PATCH 14/29] =?UTF-8?q?=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D0=B02?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lesson_3/Les3Task2.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Lesson_3/Les3Task2.py b/Lesson_3/Les3Task2.py index 9d15d98..d0eddbf 100644 --- a/Lesson_3/Les3Task2.py +++ b/Lesson_3/Les3Task2.py @@ -1,3 +1,12 @@ -a=2 -b=3 -c=4 \ No newline at end of file +def user_data(name,surname,year, city, mail, phone): + result=(name,surname,year, city, mail, phone) + return result +user_name=input('Имя:') +user_surname=input('Фамилия:') +user_year=input('Год рождения:') +user_city=input('Город:') +user_mail=input('Эл.почта:') +user_phone=input('Телефон:') + +user_data_1= user_data(name=user_name, surname=user_surname, year=user_year, city =user_city, mail=user_mail, phone=user_phone) +print(user_data_1) From 4783dfba6f606aa5bc72c781cea112f5789fe9ad Mon Sep 17 00:00:00 2001 From: AvokrichA Date: Sun, 14 Nov 2021 18:49:59 +0300 Subject: [PATCH 15/29] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D1=87=D0=B03?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lesson_3/Les3Task3.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Lesson_3/Les3Task3.py diff --git a/Lesson_3/Les3Task3.py b/Lesson_3/Les3Task3.py new file mode 100644 index 0000000..e034607 --- /dev/null +++ b/Lesson_3/Les3Task3.py @@ -0,0 +1,15 @@ +def list_arg(a,b,c): + min_num = min(a,b,c) + sum_num = a+b+c + return sum_num-min_num + +num_1=int(input('введите певрвое число:')) +num_2=int(input('Введите второе число:')) +num_3=int(input('Введите третье число:')) +my_list=[num_1, num_2, num_3] +result = list_arg(my_list[0], my_list[1], my_list[2]) +print(result) + + + + From 68b36f810fdd606f36cf59607c2eac6d23a229b2 Mon Sep 17 00:00:00 2001 From: AvokrichA Date: Sun, 14 Nov 2021 19:20:51 +0300 Subject: [PATCH 16/29] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D1=87=D0=B04?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lesson_3/Les3Task4.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Lesson_3/Les3Task4.py diff --git a/Lesson_3/Les3Task4.py b/Lesson_3/Les3Task4.py new file mode 100644 index 0000000..2d02a32 --- /dev/null +++ b/Lesson_3/Les3Task4.py @@ -0,0 +1,19 @@ +# Вариант решения-1 + +# def deg_arg(a,b): +# return pow(a, b) +# num_1=float(input('Введите целое положительное число:')) +# num_2=int(input('Введите целое отрицательное число:')) +# +# result = deg_arg(num_1, num_2) +# print(result)] + +# Вариант решения-2 + +def deg_arg(a,b): + return a**b +num_1=float(input('Введите целое положительное число:')) +num_2=int(input('Введите целое отрицательное число:')) + +result = deg_arg(num_1, num_2) +print(result) \ No newline at end of file From ca461fb0dce2682693f0cde227f310caf43ac775 Mon Sep 17 00:00:00 2001 From: AvokrichA Date: Mon, 15 Nov 2021 15:45:44 +0300 Subject: [PATCH 17/29] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D1=87=D0=B05?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lesson_3/Les3Task5.py | 17 +++++++++++++++++ Lesson_3/Les3Task6.py | 7 +++++++ 2 files changed, 24 insertions(+) create mode 100644 Lesson_3/Les3Task5.py create mode 100644 Lesson_3/Les3Task6.py diff --git a/Lesson_3/Les3Task5.py b/Lesson_3/Les3Task5.py new file mode 100644 index 0000000..36e2681 --- /dev/null +++ b/Lesson_3/Les3Task5.py @@ -0,0 +1,17 @@ +def list_num(num_list, stop): + nums=num_list.split(' ') + total=0 + for x in nums: + if x == stop: + break + total+= int(x) + return total +end = '=' +fin=False +n=0 +while not fin: + user_num = input('Введите числа:') + n+= list_num(user_num, end) + fin=end in user_num + print(f"Sum={n}") + diff --git a/Lesson_3/Les3Task6.py b/Lesson_3/Les3Task6.py new file mode 100644 index 0000000..2626f23 --- /dev/null +++ b/Lesson_3/Les3Task6.py @@ -0,0 +1,7 @@ +def user_words(txt): + text = txt[0].upper()+txt[1:].lower() + return text + +string = input('Введите слова с маленькой буквы:') +for text in string.split(' '): + print(f'{user_words(text)}', end=' ') From 49c0a2dbb8cd18b919014d32a888a7df5a217f50 Mon Sep 17 00:00:00 2001 From: AvokrichA Date: Thu, 18 Nov 2021 17:26:25 +0300 Subject: [PATCH 18/29] Lesson2 --- Lesson_4/Les4_Task1.py | 5 +++-- Lesson_4/Les4_Task2.py | 13 +++++++++++-- Lesson_4/Les4_Task3.py | 6 ++++++ Lesson_4/My_script.py | 7 +++++++ 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 Lesson_4/Les4_Task3.py create mode 100644 Lesson_4/My_script.py diff --git a/Lesson_4/Les4_Task1.py b/Lesson_4/Les4_Task1.py index 36f001d..1bf9eeb 100644 --- a/Lesson_4/Les4_Task1.py +++ b/Lesson_4/Les4_Task1.py @@ -1,2 +1,3 @@ -a=10 -print(a) \ No newline at end of file +python My_script раз 2 true + + diff --git a/Lesson_4/Les4_Task2.py b/Lesson_4/Les4_Task2.py index 36f001d..a1545e3 100644 --- a/Lesson_4/Les4_Task2.py +++ b/Lesson_4/Les4_Task2.py @@ -1,2 +1,11 @@ -a=10 -print(a) \ No newline at end of file +my_list= [300, 2, 12, 44, 1, 1, 4, 10, 7, 1, 78, 123, 55] + +# filtred_list=[] +# for i in range(1, len(my_list)): +# if my_list[i]>my_list[i-1]: +# filtred_list.append(my_list[i]) +# print(filtred_list) + + +filtred_list = [my_list[i] for i in range(1, len(my_list)) if my_list[i]>my_list[i-1]] +print(filtred_list) diff --git a/Lesson_4/Les4_Task3.py b/Lesson_4/Les4_Task3.py new file mode 100644 index 0000000..acceb90 --- /dev/null +++ b/Lesson_4/Les4_Task3.py @@ -0,0 +1,6 @@ +number = 0 +n = int(input('Введите n')) +while number <= n: + if number % 2 != 0: + print(number) + number+=1 diff --git a/Lesson_4/My_script.py b/Lesson_4/My_script.py new file mode 100644 index 0000000..e995763 --- /dev/null +++ b/Lesson_4/My_script.py @@ -0,0 +1,7 @@ +from sys import argv +if len(argv)<4 +print('Выработка в часах' time) +print('Ставка в час', bet) +print('Премия', prize) +def my_salary(time, bet, prize): + return time*bet+prize From 44195d6801b7810d79e5e9514f27067d71d601fb Mon Sep 17 00:00:00 2001 From: AvokrichA Date: Fri, 19 Nov 2021 15:55:25 +0300 Subject: [PATCH 19/29] Lesson4 --- Lesson_4/Les4_Task1.py | 8 ++++++-- Lesson_4/Les4_Task3.py | 15 +++++++++------ Lesson_4/Les4_Task4.py | 10 ++++++++++ Lesson_4/Les4_Task5.py | 11 +++++++++++ Lesson_4/Les4_Task6.py | 14 ++++++++++++++ Lesson_4/Les4_Task7.py | 8 ++++++++ Lesson_4/My_script.py | 11 +++++------ Lesson_4/Test.py | 1 + test.py | 1 + 9 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 Lesson_4/Les4_Task4.py create mode 100644 Lesson_4/Les4_Task5.py create mode 100644 Lesson_4/Les4_Task6.py create mode 100644 Lesson_4/Les4_Task7.py create mode 100644 Lesson_4/Test.py create mode 100644 test.py diff --git a/Lesson_4/Les4_Task1.py b/Lesson_4/Les4_Task1.py index 1bf9eeb..3ee68e9 100644 --- a/Lesson_4/Les4_Task1.py +++ b/Lesson_4/Les4_Task1.py @@ -1,3 +1,7 @@ -python My_script раз 2 true - +from sys import argv +print(argv) +if len(argv)<3: + print('Введите три параметра: 1.Выработка в часах, 2.Ставка в час, 3.Премия') +else: + print(f'Salary= {float(argv[1]) * float(argv[2]) + float(argv[3])}') diff --git a/Lesson_4/Les4_Task3.py b/Lesson_4/Les4_Task3.py index acceb90..613f026 100644 --- a/Lesson_4/Les4_Task3.py +++ b/Lesson_4/Les4_Task3.py @@ -1,6 +1,9 @@ -number = 0 -n = int(input('Введите n')) -while number <= n: - if number % 2 != 0: - print(number) - number+=1 +my_list=list(range(20,241,1)) +# filtred_list=[] +# for i in range(1, len(my_list)): +# if my_list[i]%20==0 or my_list[i]%21==0: +# filtred_list.append(my_list[i]) +# print(filtred_list) + +filtred_list = [my_list[i] for i in range(1, len(my_list)) if my_list[i]%20==0 or my_list[i]%21==0] +print(filtred_list) diff --git a/Lesson_4/Les4_Task4.py b/Lesson_4/Les4_Task4.py new file mode 100644 index 0000000..ff5e8af --- /dev/null +++ b/Lesson_4/Les4_Task4.py @@ -0,0 +1,10 @@ +my_list= [2, 2, 2, 7, 23, 1, 44, 44, 3, 2, 10, 7, 4, 11] + +# filtred_list=[] +# for i in my_list: +# if my_list.count(i)==1: +# filtred_list.append(i) +# print(filtred_list) + +filtred_list = [ i for i in my_list if my_list.count(i)==1] +print(filtred_list) diff --git a/Lesson_4/Les4_Task5.py b/Lesson_4/Les4_Task5.py new file mode 100644 index 0000000..2518293 --- /dev/null +++ b/Lesson_4/Les4_Task5.py @@ -0,0 +1,11 @@ +from functools import reduce +# num_list=[] +# for i in range(100,1001): +# if i%2==0: +# num_list.append(i) +# total=reduce(lambda x, y: x * y, num_list) +# print(total) + +num_list=[i for i in range(100,1001) if i%2==0] +total=reduce(lambda x, y: x * y, num_list) +print(total) \ No newline at end of file diff --git a/Lesson_4/Les4_Task6.py b/Lesson_4/Les4_Task6.py new file mode 100644 index 0000000..7f2d83d --- /dev/null +++ b/Lesson_4/Les4_Task6.py @@ -0,0 +1,14 @@ +from itertools import count, cycle + +for i in count(3): + if i>10: + break + print(i) + +my_list = [3, 15, 18, 42] +counter = 0 +for i in cycle(my_list): + counter += 1 + if counter > 10: + break + print(i) \ No newline at end of file diff --git a/Lesson_4/Les4_Task7.py b/Lesson_4/Les4_Task7.py new file mode 100644 index 0000000..8baa8dd --- /dev/null +++ b/Lesson_4/Les4_Task7.py @@ -0,0 +1,8 @@ +def fact(num): + num_1 = 1 + for i in range(1, num + 1): + num_1 *= i + yield num_1 +x = 10 +for y, z in enumerate(fact(x)): + print(f'!{y+1} {z}') diff --git a/Lesson_4/My_script.py b/Lesson_4/My_script.py index e995763..9f38dbc 100644 --- a/Lesson_4/My_script.py +++ b/Lesson_4/My_script.py @@ -1,7 +1,6 @@ from sys import argv -if len(argv)<4 -print('Выработка в часах' time) -print('Ставка в час', bet) -print('Премия', prize) -def my_salary(time, bet, prize): - return time*bet+prize +print(argv) +if len(argv)<3: + print('Введите три параметра: 1.Выработка в часах, 2.Ставка в час, 3.Премия') +else: + print(f'Salary= {int(argv[1]) * int(argv[2]) + int(argv[3])}') \ No newline at end of file diff --git a/Lesson_4/Test.py b/Lesson_4/Test.py new file mode 100644 index 0000000..7111bdd --- /dev/null +++ b/Lesson_4/Test.py @@ -0,0 +1 @@ +print(f'This is python script!') diff --git a/test.py b/test.py new file mode 100644 index 0000000..7111bdd --- /dev/null +++ b/test.py @@ -0,0 +1 @@ +print(f'This is python script!') From 76699c7c3a899590a093b65d3dec6110c3836317 Mon Sep 17 00:00:00 2001 From: Alexandra Chirkova <93881730+AvokrichA@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:25:33 +0300 Subject: [PATCH 20/29] =?UTF-8?q?Create=20=D0=9F=D0=BE=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=5F3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...320\266\320\265\320\275\320\270\320\265_3" | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 "\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_3" diff --git "a/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_3" "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_3" new file mode 100644 index 0000000..d95ef9f --- /dev/null +++ "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_3" @@ -0,0 +1,75 @@ +# Дан список повторяющихся элементов. Вернуть список с дублирующимися элементами. +# В результирующем списке не должно быть дубликатов. + +my_list = ['День', 'Ночь', 'День', 1, 1, 51, '51', 1, '1'] +print(f"Мой список: {my_list}") +duplicates = [] + +for item in my_list: + if my_list.count(item) > 1 and item not in duplicates: + duplicates.append(item) + +print(f'Повторяющиеся элементы в списке: {duplicates}') + +# В большой текстовой строке подсчитать количество встречаемых слов и вернуть 10 самых частых. +# Не учитывать знаки препинания и регистр символов. За основу возьмите любую статью из википедии +# или из документации к языку. + +long_string = ''' +Сегодня королевский питон для любителей экзотических домашних животных одна из самых популярных змей. В природных условиях этот вид змей живет в западной части Африки. Излюбленное место его обитания — саванны и открытые леса неподалёку от воды, в которой змеи спасаются от жары, но все же основное время они проводят в норах. Королевский питон активен вечером и ночью, именно тогда он охотится на птиц, ящериц, мелких млекопитающих. + +В неволе при хорошем уходе, королевские питоны чувствуют себя очень комфортно, они не привередливы. Могут укусить, но это скорее редкость, чем обычное явление, так как к этой форме защиты прибегают только в экстренных случаях, обычно сворачиваются в тугой клубок — шарик, за это королевского питона также называют «шаровой питон». + +Продолжительность жизни: на воле — 10 лет, в домашних условиях живут до 30-40 лет. + +Половая зрелость — в возрасте 3-5 лет. Королевский питон один из тех, кто довольно легок в содержании, ухаживать за ним для любителей животных не составит особого труда. Для них необходим просторный стеклянный или пластиковый террариум, в юном возрасте ( пока не вырастут до 90 см) можно содержать и в 35-литровом террариуме, а затем, когда подрастут – стоит увеличить и место их жительства. Периметр их «квартиры» должен превышать длину жильцов как минимум в два раза, чтобы было, где развернуться. + +Обязательное условие содержания в домашних условиях этой змеи – это наличие крышки у террариума, вы ведь не хотите, чтобы ваш питомец отправился гулять по комнате. Кроме того крышка должна иметь отверстия для обеспечения вентиляции. Для подстилки можно использовать бумажные полотенца, газету, искусственный субстрат, а вот древесные опилки вам для этой цели точно не подойдут. + +Так как в природе питон королевский любит прятаться, то и в неволе нужно создать для него такие укромные места. Оптимальная температура для жизнедеятельности питона – 25-29 оC днем, а ночью – 20-23 оС. Для обогрева можно использовать греющие коврики. Для купания питомца нужно сделать в его жилище небольшой водоем, следите, чтобы вода в нем всегда была чистой. Особый момент в уходе за королевскими питонами – питание. Их можно кормить замороженными мышами, крысами, цыплятами, хомяками, живыми животными можно кормить при условии их предварительного оглушения, чтобы избежать травм. Периодичность кормлений зависит от возраста и размера питона. Для молодых - 1 раз в пять дней, взрослым достаточно 1 раза в 10 дней. И не стоит забывать о витаминных добавках, чтобы ваш питомец получал все необходимые для здоровья вещества. +''' + +print(long_string) + +symbols="1234567890-—/\[]().:><,!?""''" +for symbol in symbols: + big_string = long_string.replace(symbol, " ") +big_string = long_string.lower() +my_list = long_string.split() +my_dict = dict() +for word in my_list: + if my_dict.get(word) == None: my_dict[word] = 1 + else: my_dict[word] += 1 + +sorted_dict = sorted(my_dict.items(), key=lambda x: x[1], reverse=True) +print(sorted_dict[:10]) + + +# Создайте словарь со списком вещей для похода в качестве ключа и их массой в качестве значения. +# Определите какие вещи влезут в рюкзак передав его максимальную грузоподъёмность. +# Достаточно вернуть один допустимый вариант.*Верните все возможные варианты комплектации рюкзака. + +import random +my_items = { 'палатка': 2500, + 'спальный мешок': 1000, + 'мангал': 700, + 'шампура': 700, + 'спички': 10, + 'уголь': 8000, + 'рыболовные снасти': 500, + 'складной стул': 300 + } + +max_weight = 10000 +count = 0 +result = [] +while count <= max_weight: + key, value = random.choice(list(my_items.items())) + if key in result: + continue + if count + value > max_weight: + break + count += value + result += (str(key), str(value)) + +print(f'{result} = {count}') From f5af4dc138324ac7032bd088cd67068609d8c31b Mon Sep 17 00:00:00 2001 From: Alexandra Chirkova <93881730+AvokrichA@users.noreply.github.com> Date: Tue, 30 Jan 2024 19:39:45 +0300 Subject: [PATCH 21/29] =?UTF-8?q?Create=20=D0=9F=D0=BE=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=5F4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...320\266\320\265\320\275\320\270\320\265_4" | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 "\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_4" diff --git "a/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_4" "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_4" new file mode 100644 index 0000000..c5841f0 --- /dev/null +++ "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_4" @@ -0,0 +1,41 @@ +''' +Напишите функцию для транспонирования матрицы. +''' + + +def transpose_matrix(matrix): + rows = len(matrix) + cols = len(matrix[0]) + transpose = [[0 for j in range(rows)] for i in range(cols)] + for i in range(rows): + for j in range(cols): + transpose[j][i] = matrix[i][j] + return transpose + + +def print_(matrix_): + for row in matrix_: + for x in row: + print(x, end=" ") + print() + + +my_matrix = [[10, 20], [35, 45], [56, 35], [35, 76]] +print_(my_matrix) +print() +print_(transpose_matrix(my_matrix)) + +''' +Напишите функцию принимающую на вход только ключевые параметры и возвращающую словарь, где ключ — значение переданного +аргумента, а значение — имя аргумента. Если ключ не хешируем, используйте его строковое представление. +''' +def my_func(**kwargs): + my_dict = dict() + for key, value in kwargs.items(): + if isinstance(value, (list, dict, set)): + value = str(value) + my_dict[value] = key + return my_dict + + +print(my_func(компании=['Рога', 'Копыта', 'Хвосты'], учредители={1: 'Петров', 2: 'Сидоров'})) From e5f8cbf9420aa68abbc7c950118a2eb8be73c4c4 Mon Sep 17 00:00:00 2001 From: Alexandra Chirkova <93881730+AvokrichA@users.noreply.github.com> Date: Fri, 2 Feb 2024 01:22:56 +0300 Subject: [PATCH 22/29] =?UTF-8?q?Create=20=D0=9F=D0=BE=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...320\266\320\265\320\275\320\270\320\265 5" | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265 5" diff --git "a/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265 5" "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265 5" new file mode 100644 index 0000000..6daf6c8 --- /dev/null +++ "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265 5" @@ -0,0 +1,36 @@ +#2. Напишите функцию, которая принимает на вход строку +# - абсолютный путь до файла. Функция возвращает кортеж из трёх элементов: путь, имя файла, расширение файла. + +my_way= r'C:\Users\Pobeda\Desktop\geekbrains\Погружение в Python\Home_Task.py' +def my_func(my_way): + *a, b = my_way.split("\\") + *c, d = b.split(".") + c = ".".join(c) + a = "/".join(a) + return a,c,d + +print(my_func(my_way)) + +# 3. Напишите однострочный генератор словаря, который принимает на вход три списка одинаковой длины: +# имена str, ставка int, премия str с указанием процентов вида “10.25%”. В результате получаем +# словарь с именем в качестве ключа и суммой премии в качестве значения. Сумма рассчитывается как ставка +# умноженная на процент премии + + +names = ["Иван", "Николай", "Петр"] +salarys = [125000, 96000, 109000] +awards = ["10.0%", "25.00%", "13.00%"] +my_dict = {names: salarys + ((salarys /100) * float(awards.replace('%', ' '))) for names, salarys, awards in zip(names, salarys, awards)} +print(my_dict) + + + +# 4. Создайте функцию генератор чисел Фибоначчи +a = int(input('Укажите количество элементов: ')) + +def fib(x): + a, b = 0, 1 + for i in range(x): + yield a + a, b = b, a + b +print(list(fib(a))) From 23a39cfe540183dbe20a52fcfbbba78da1bee408 Mon Sep 17 00:00:00 2001 From: Alexandra Chirkova <93881730+AvokrichA@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:53:35 +0300 Subject: [PATCH 23/29] =?UTF-8?q?Create=20=D0=9F=D0=BE=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=5F6=5F2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\266\320\265\320\275\320\270\320\265_6_2" | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 "\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_6_2" diff --git "a/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_6_2" "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_6_2" new file mode 100644 index 0000000..b95063e --- /dev/null +++ "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_6_2" @@ -0,0 +1,37 @@ +#В модуль с проверкой даты добавьте возможность запуска в терминале с передачей даты на проверку. + +from sys import argv +def _is_leap(year:int)->bool: + return year%4 == 0 and year%100 !=0 or year%400 == 0 + +def data_is_true(data:str)->bool: + day, month, year = list(map(int, data.split('.'))) + check_days = { + 1:31, + 2:28 if _is_leap(year) else 28, + 3:31, + 4:30, + 5:31, + 6:30, + 7:31, + 8:31, + 9:30, + 10:31, + 11:30, + 12:31 + } + + max_day = check_days.get(month) + if not max_day or (year > 9999 or year < 1) or (max_day < day or day < 1): + return False + else: + return True + + +if __name__=='__main__': + if len(argv) == 2: + _, date = argv + print(f"{date} {data_is_true(date)}") + else: + date = input('Введите дату в формате DD.MM.YYYY: ') + print(f"{date} {data_is_true(date)}") From 866343a1f888f20b89f658834c1a7197dd711d2a Mon Sep 17 00:00:00 2001 From: Alexandra Chirkova <93881730+AvokrichA@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:54:36 +0300 Subject: [PATCH 24/29] =?UTF-8?q?Update=20=D0=9F=D0=BE=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=5F6=5F2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...321\200\321\203\320\266\320\265\320\275\320\270\320\265_6_2" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_6_2" "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_6_2" index b95063e..7de7c79 100644 --- "a/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_6_2" +++ "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_6_2" @@ -1,5 +1,5 @@ #В модуль с проверкой даты добавьте возможность запуска в терминале с передачей даты на проверку. - +__all__ = ['data_is_true'] from sys import argv def _is_leap(year:int)->bool: return year%4 == 0 and year%100 !=0 or year%400 == 0 From 5eface0879ed73834228d08f164168d2d80de359 Mon Sep 17 00:00:00 2001 From: Alexandra Chirkova <93881730+AvokrichA@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:19:30 +0300 Subject: [PATCH 25/29] =?UTF-8?q?Create=20=D0=9F=D0=BE=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=5F7=5F2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\266\320\265\320\275\320\270\320\265_7_2" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_7_2" diff --git "a/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_7_2" "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_7_2" new file mode 100644 index 0000000..a6ad1a0 --- /dev/null +++ "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_7_2" @@ -0,0 +1,32 @@ +''' +Напишите функцию группового переименования файлов. Она должна: +a. принимать параметр желаемое конечное имя файлов. При переименовании в конце имени добавляется порядковый номер. +b. принимать параметр количество цифр в порядковом номере. +c. принимать параметр расширение исходного файла. Переименование должно работать только для этих файлов внутри каталога. +d. принимать параметр расширение конечного файла. +e. принимать диапазон сохраняемого оригинального имени. Например для диапазона [3, 6] берутся буквы с 3 по 6 из +исходного имени файла. К ним прибавляется желаемое конечное имя, если оно передано. Далее счётчик файлов и расширение. +''' + +import os +from pathlib import Path + + +def files_rename(path_, source_ext, fin_ext, range_=[0, 0], numc=3, new_name="new"): + my_files = [file for file in os.listdir(path_) if file.lower().endswith(source_ext)] + count = 1 + + for file in my_files: + file_name, ext = os.path.splitext(file) + file_name = file_name[range_[0] - 1:range_[1]] + new_name + new_file = f"{file_name}{str(counter).zfill(numc)}.{fin_ext}" + os.rename(os.path.join(path_, file), os.path.join(path_, new_file)) + count += 1 + + +if __name__ == "__main__": + my_path = Path().cwd() /'geekbrains'/ "Погружение в Python" / "Home_Task_7_2" + print(my_path) + print(f"{my_path=}") + print(f"files: {os.listdir(my_path)}") + files_rename(my_path, "txt", "txt", numc=2, new_name="new", range_=[1, 2]) From 475dc85ea8baf376344bfc2765288ec6dcd81f42 Mon Sep 17 00:00:00 2001 From: Alexandra Chirkova <93881730+AvokrichA@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:35:30 +0300 Subject: [PATCH 26/29] =?UTF-8?q?Create=20=D0=9F=D0=BE=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=5F7=5F1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\266\320\265\320\275\320\270\320\265_7_1" | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 "\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_7_1" diff --git "a/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_7_1" "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_7_1" new file mode 100644 index 0000000..806c8ec --- /dev/null +++ "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_7_1" @@ -0,0 +1,65 @@ +# 2. Треугольник существует только тогда, когда сумма любых двух его сторон больше третьей. +# Дано a, b, c - стороны предполагаемого треугольника. Требуется сравнить длину каждого +# отрезка-стороны с суммой двух других. Если хотя бы в одном случае отрезок окажется больше +# суммы двух других, то треугольника с такими сторонами не существует. Отдельно сообщить является +# ли треугольник разносторонним, равнобедренным или равносторонним. + +# a = float(input("Введите длину стороны a: ")) +# b = float(input("Введите длину стороны b: ")) +# c = float(input("Введите длину стороны c: ")) + +# if a + b <= c or a + c <= b or b + c <= a: +# print("Треугольник не может существовать.") +# else: +# if a == b == c: +# print("Треугольник является равносторонним.") +# elif a == b or a == c or b == c: +# print("Треугольник является равнобедренным.") +# else: +# print("Треугольник является разносторонним.") + + + +# 3. Напишите код, который запрашивает число и сообщает является ли оно простым или составным. +# Используйте правило для проверки: “Число является простым, если делится нацело только на единицу +# и на себя”. Сделайте ограничение на ввод отрицательных чисел и чисел больше 100 тысяч. + +# num = int(input("Введите число: ")) + +# if num <= 1 or num > 100_000: +# print("Число должно быть в диапазоне от 2 до 100_000.") +# else: +# is_prime = True +# for i in range(2, num): +# if num % i == 0: +# is_prime = False +# break +# print('Простое число' if is_prime else 'Составное число') + + + +# 4. Программа загадывает число от 0 до 1000. Необходимо угадать число за 10 попыток. +# Программа должна подсказывать «больше» или «меньше» после каждой попытки. + +# import random + +# num = random.randint(0, 1000) +# guess = None +# flag = False +# attempts = 0 + +# print("Загадано число от 0 до 1000. У тебя есть 10 попыток, чтобы его угадать.") + +# while attempts < 10: +# guess = int(input("Введи свой вариант: ")) +# attempts += 1 +# if guess == num: +# print(f"Ура! Ты угадал число {num} за {attempts} попыток.") +# guess = True +# break +# elif guess < num: +# print("Загаданное число больше.") +# else: +# print("Загаданное число меньше.") + +# print(f"У тебя закончились попытки. Загаданное число было {num}." if not flag else '') From 7a9798cb53a6a6db30d4f97df5d8fcee072692c0 Mon Sep 17 00:00:00 2001 From: Alexandra Chirkova <93881730+AvokrichA@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:35:50 +0300 Subject: [PATCH 27/29] =?UTF-8?q?Rename=20=D0=9F=D0=BE=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=5F7=5F1=20to=20=D0=9F=D0=BE?= =?UTF-8?q?=D0=B3=D1=80=D1=83=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=5F1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_1" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_7_1" => "\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_1" (100%) diff --git "a/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_7_1" "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_1" similarity index 100% rename from "\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_7_1" rename to "\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_1" From eb0813a36d920bfb34ec55b564078a9c04e4444f Mon Sep 17 00:00:00 2001 From: Alexandra Chirkova <93881730+AvokrichA@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:37:30 +0300 Subject: [PATCH 28/29] =?UTF-8?q?Create=20=D0=9F=D0=BE=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=5F2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...320\266\320\265\320\275\320\270\320\265_2" | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 "\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_2" diff --git "a/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_2" "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_2" new file mode 100644 index 0000000..3f24889 --- /dev/null +++ "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_2" @@ -0,0 +1,66 @@ +# 2. Напишите программу, которая получает целое число и возвращает его шестнадцатеричное +# строковое представление. Функцию hex используйтe для проверки своего результата. + +# def recalculation_number_system(number): +# string_to_translate = '0123456789ABCDEF' +# result = '' +# notation = 16 + +# while number > 0: +# result = string_to_translate[number % notation] + result +# number //= notation + +# return result + +# print('Итог - ', recalculation_number_system(int(input('Введите число для перевода в 16-ю систему счисления: ')))) + + + +# 3. Напишите программу, которая принимает две строки вида “a/b” - дробь с числителем и знаменателем. +# Программа должна возвращать сумму и произведение* дробей. Для проверки своего кода используйте модуль fractions. + +# def fraction_conversion(number): +# numerator, denominator = number.split('/') +# return int(numerator), int(denominator) + + +# def reduction(nom, den): +# def all_devs(number): +# all_dev = set() +# for dev in range(1, number // 1 + 1): +# if not number % dev: +# all_dev.add(dev) +# return all_dev + +# nom_dev = all_devs(nom) +# den_dev = all_devs(den) +# reduct = max(nom_dev.intersection(den_dev)) + +# return str(nom // reduct), str(den // reduct) + + +# def summ(first_number, second_number): +# first, second = fraction_conversion(first_number), fraction_conversion(second_number) + +# if first[1] == second[1]: +# nom = first[0] + second[0] +# den = first[1] +# return '/'.join(reduction(num, den)) +# else: +# nom = first[0] * second[1] + first[1] * second[0] +# den = first[1] * second[1] +# return '/'.join(reduction(nom, den)) + + +# def multi(first_number, second_number): +# first, second = fraction_conversion(first_number), fraction_conversion(second_number) +# nom = first[0] * second[0] +# den = first[1] * second[1] +# return '/'.join(reduction(nom, den)) + + +# first_number = input('Введите первую дробь в формате a/b: ') +# second_number = input('Введите вторую дробь в формате a/b: ') + +# print(f'Summa: {summ(first_number, second_number)}') +# print(f'Multiplication: {multi(first_number, second_number)}') From 0f68cc919c03110bef682df3eb381171c96d396b Mon Sep 17 00:00:00 2001 From: Alexandra Chirkova <93881730+AvokrichA@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:42:41 +0300 Subject: [PATCH 29/29] =?UTF-8?q?Create=20=D0=9F=D0=BE=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=5F8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...320\266\320\265\320\275\320\270\320\265_8" | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 "\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_8" diff --git "a/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_8" "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_8" new file mode 100644 index 0000000..ccd1102 --- /dev/null +++ "b/\320\237\320\276\320\263\321\200\321\203\320\266\320\265\320\275\320\270\320\265_8" @@ -0,0 +1,55 @@ +''' + +Напишите функцию, которая получает на вход директорию и рекурсивно обходит её и все вложенные директории. +Результаты обхода сохраните в файлы json, csv и pickle. +Для дочерних объектов указывайте родительскую директорию. +Для каждого объекта укажите файл это или директория. +Для файлов сохраните его размер в байтах, а для директорий размер файлов в ней с учётом всех вложенных файлов и директорий. +''' + +import json +import os +import csv +import pickle +from os.path import join, getsize + + +def my_directory(file_path): + for root, dirs, files in os.walk(file_path): + folder = root.split('\\') + + + print(f'В директории {folder[-1]}', end="\n") + if not dirs: + print("В этой папке нет директорий") + else: + + print(f'Директория(и) {dirs}', end="\n") + print(f'Файл(ы) {files}', end="\n") + print(sum(getsize(join(root, name)) for name in files), end="\n") + + + + str_json = " ".join(files) + to_json = {root: dirs, 'files': str_for_json, 'Size': sum(getsize(join(root, name)) for name in files) } + with open('to_json.json', 'a') as f: + json.dump(to_json, f, sort_keys=True, indent=2) + + with open('for_csv.csv', 'a', newline='') as csvfile: + fieldnames = ['files', 'dirs'] + writer = csv.DictWriter(csvfile, fieldnames=fieldnames) + + writer.writeheader() + writer.writerow({'files': str_json, 'dirs': dirs}) + + + with open('data.pickle', 'wb') as f: + pickle.dump(to_json, f) + + with open('data.pickle', 'rb') as f: + ... + data_new = pickle.load(f) + print(data_new) + + +my_directory(os.curdir)