From 5beaef7f470cc9c5292f958aadc7b38c68911c80 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 21 Sep 2019 15:48:36 +0300 Subject: [PATCH 01/41] t1 --- t1.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 t1.py diff --git a/t1.py b/t1.py new file mode 100644 index 0000000..9ceaf38 --- /dev/null +++ b/t1.py @@ -0,0 +1,2 @@ +n = int(input()) +print(n // 60 % 24, ":", n % 60) \ No newline at end of file From e07ebff73efef913f7b346ee2383e760ab988c18 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 21 Sep 2019 16:01:31 +0300 Subject: [PATCH 02/41] problems 2-9 --- t2.py | 3 +++ t3.py | 2 ++ t4.py | 5 +++++ t5.py | 6 ++++++ t6.py | 14 ++++++++++++++ t7.py | 8 ++++++++ t8.py | 8 ++++++++ t9.py | 7 +++++++ 8 files changed, 53 insertions(+) create mode 100644 t2.py create mode 100644 t3.py create mode 100644 t4.py create mode 100644 t5.py create mode 100644 t6.py create mode 100644 t7.py create mode 100644 t8.py create mode 100644 t9.py diff --git a/t2.py b/t2.py new file mode 100644 index 0000000..f6e02f4 --- /dev/null +++ b/t2.py @@ -0,0 +1,3 @@ +text = str(input()) +n = int(input()) +print("Hello" + (", " + text) * n) \ No newline at end of file diff --git a/t3.py b/t3.py new file mode 100644 index 0000000..f885a2a --- /dev/null +++ b/t3.py @@ -0,0 +1,2 @@ +a, b, c = map(int, input().split()) +print(min(min(a, b), c)) \ No newline at end of file diff --git a/t4.py b/t4.py new file mode 100644 index 0000000..040788f --- /dev/null +++ b/t4.py @@ -0,0 +1,5 @@ +v, t = map(int, input().split()) +if v > 0: + print((v * t) % 109) +else: + print(109 - (abs(v) * t) % 109) \ No newline at end of file diff --git a/t5.py b/t5.py new file mode 100644 index 0000000..b0e5541 --- /dev/null +++ b/t5.py @@ -0,0 +1,6 @@ +import math +n = int(input()) +s = 0 +for i in range(1, n + 1): + s += math.factorial(i) +print(s) \ No newline at end of file diff --git a/t6.py b/t6.py new file mode 100644 index 0000000..8cce798 --- /dev/null +++ b/t6.py @@ -0,0 +1,14 @@ +a = [] +c = int(input()) +while c != 0: + a.append(c) + c = int(input()) +max_a = 0 +max2_a = 0 +for i in range(len(a)): + if a[i] > max_a: + max_a = a[i] +for i in range(len(a)): + if a[i] > max2_a and a[i] != max_a: + max2_a = a[i] +print(max2_a) \ No newline at end of file diff --git a/t7.py b/t7.py new file mode 100644 index 0000000..a8c8c8e --- /dev/null +++ b/t7.py @@ -0,0 +1,8 @@ +a = [] +c = int(input()) +while c != 0: + a.append(c) + c = int(input()) +for i in range(len(a)): + if i % 2 == 1: + print(a[i]) \ No newline at end of file diff --git a/t8.py b/t8.py new file mode 100644 index 0000000..9839262 --- /dev/null +++ b/t8.py @@ -0,0 +1,8 @@ +a = [] +c = int(input()) +while c != 0: + a.append(c) + c = int(input()) +for i in range(len(a)): + if a[i] % 2 == 0: + print(a[i]) \ No newline at end of file diff --git a/t9.py b/t9.py new file mode 100644 index 0000000..15909c0 --- /dev/null +++ b/t9.py @@ -0,0 +1,7 @@ +import math +def distance(x1, x2, y1, y2): + return(math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)) + + +x1, y1, x2, y2 = map(int, input().split()) +print(r(x1, x2, y1, y2)) \ No newline at end of file From 443fedde2105640f737c203a402c4aa09b4721fe Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 5 Oct 2019 18:45:20 +0300 Subject: [PATCH 03/41] week 3 task 2 --- w03t2.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 w03t2.py diff --git a/w03t2.py b/w03t2.py new file mode 100644 index 0000000..a814054 --- /dev/null +++ b/w03t2.py @@ -0,0 +1,12 @@ +import turtle + +turtle.shape('turtle') +turtle.forward(50) +turtle.left(90) +turtle.forward(50) +turtle.left(90) +turtle.forward(50) +turtle.right(90) +turtle.forward(50) +turtle.right(90) +turtle.forward(50) \ No newline at end of file From 26860db47cea74e2c77a6cf620759c86ae78fd86 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 5 Oct 2019 18:52:27 +0300 Subject: [PATCH 04/41] week 3 task 3 --- w3t3.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 w3t3.py diff --git a/w3t3.py b/w3t3.py new file mode 100644 index 0000000..996c221 --- /dev/null +++ b/w3t3.py @@ -0,0 +1,11 @@ +import turtle + +turtle.shape('turtle') +turtle.forward(40) +turtle.left(90) +turtle.forward(40) +turtle.left(90) +turtle.forward(40) +turtle.left(90) +turtle.forward(40) +turtle.left(90) \ No newline at end of file From 46950f35dc28f216f842c098a97d5b5e2ad10b3c Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 5 Oct 2019 18:57:46 +0300 Subject: [PATCH 05/41] week3 task3 --- w3t3.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/w3t3.py b/w3t3.py index 996c221..bcb7d7b 100644 --- a/w3t3.py +++ b/w3t3.py @@ -1,11 +1,6 @@ import turtle turtle.shape('turtle') -turtle.forward(40) -turtle.left(90) -turtle.forward(40) -turtle.left(90) -turtle.forward(40) -turtle.left(90) -turtle.forward(40) -turtle.left(90) \ No newline at end of file +for i in range(4): + turtle.forward(40) + turtle.left(90) \ No newline at end of file From b5021b28798ac33e93cfc0b170b92c2864c0719f Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 5 Oct 2019 19:00:41 +0300 Subject: [PATCH 06/41] week3 task4 --- w3t4.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 w3t4.py diff --git a/w3t4.py b/w3t4.py new file mode 100644 index 0000000..141e94e --- /dev/null +++ b/w3t4.py @@ -0,0 +1,6 @@ +import turtle + +turtle.shape('turtle') +for i in range(360): + turtle.forward(2) + turtle.left(1) \ No newline at end of file From d935eceff3ad83550c5c84c298e2c5d0558d8e7c Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 5 Oct 2019 19:12:49 +0300 Subject: [PATCH 07/41] week3 task5 --- w3t5.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 w3t5.py diff --git a/w3t5.py b/w3t5.py new file mode 100644 index 0000000..26fe24a --- /dev/null +++ b/w3t5.py @@ -0,0 +1,14 @@ +import turtle + +turtle.shape('turtle') +for i in range(1, 11): + turtle.forward(i * 20) + for j in range(3): + turtle.left(90) + turtle.forward(i * 20) + turtle.penup() + turtle.forward(10) + turtle.right(90) + turtle.forward(10) + turtle.pendown() + turtle.left(180) \ No newline at end of file From 4f4adf82737d16d593b15136e5a17394d0adb797 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 5 Oct 2019 19:19:31 +0300 Subject: [PATCH 08/41] week3 task6 --- w3t6.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 w3t6.py diff --git a/w3t6.py b/w3t6.py new file mode 100644 index 0000000..e083d5f --- /dev/null +++ b/w3t6.py @@ -0,0 +1,10 @@ +import turtle + +n = int(input()) +turtle.shape('turtle') +for i in range(n): + turtle.forward(70) + turtle.stamp() + turtle.left(180) + turtle.forward(70) + turtle.left(180 - 360 // n) \ No newline at end of file From d8553729c865b8bb858c118825fb253edea7eae9 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 5 Oct 2019 19:27:51 +0300 Subject: [PATCH 09/41] week3 task7 --- w3t7.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 w3t7.py diff --git a/w3t7.py b/w3t7.py new file mode 100644 index 0000000..ed131e3 --- /dev/null +++ b/w3t7.py @@ -0,0 +1,6 @@ +import turtle + +turtle.shape('turtle') +for i in range(3600): + turtle.forward(0.1 + i * 0.001) + turtle.left(2) #по 2 градуса чтобы быстрее рисовала \ No newline at end of file From d406d63fad0331eead4ae6794756104d904791d6 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 5 Oct 2019 19:34:33 +0300 Subject: [PATCH 10/41] week3 task8 --- w3t8.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 w3t8.py diff --git a/w3t8.py b/w3t8.py new file mode 100644 index 0000000..b216395 --- /dev/null +++ b/w3t8.py @@ -0,0 +1,6 @@ +import turtle + +turtle.shape('turtle') +for i in range(4 * 10): + turtle.forward(i * 10) + turtle.left(90) \ No newline at end of file From 38e1307b22b4be48dd815ed5e9ac86cfa2ba9fff Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 5 Oct 2019 20:13:33 +0300 Subject: [PATCH 11/41] week3 task10 --- w3t10.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 w3t10.py diff --git a/w3t10.py b/w3t10.py new file mode 100644 index 0000000..24c2d90 --- /dev/null +++ b/w3t10.py @@ -0,0 +1,12 @@ +import turtle + +def circle(): + for i in range(180): + turtle.forward(1) + turtle.left(2) + +turtle.shape('turtle') +for i in range(6): + circle() + turtle.left(60) +#по 2 градуса чтобы быстрее рисовало \ No newline at end of file From 7a4fff0e024be1e05c5a785903c1e92b0b2b61ee Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 5 Oct 2019 20:23:31 +0300 Subject: [PATCH 12/41] week3 task11 --- w3t11.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 w3t11.py diff --git a/w3t11.py b/w3t11.py new file mode 100644 index 0000000..243b9e2 --- /dev/null +++ b/w3t11.py @@ -0,0 +1,19 @@ +import turtle + +def circleleft(n): + for i in range(180): + turtle.forward(n) + turtle.left(2) + +def circleright(n): + for i in range(180): + turtle.forward(n) + turtle.right(2) + +turtle.shape('turtle') +turtle.left(90) +l = 0 +for i in range(1, 11): + l += 0.5 + circleleft(l) + circleright(l) \ No newline at end of file From 1736cb0ebb5356f4e88bf8d74baeaaa2f4270fb7 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 5 Oct 2019 20:27:52 +0300 Subject: [PATCH 13/41] week3 task12 --- w3t12.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 w3t12.py diff --git a/w3t12.py b/w3t12.py new file mode 100644 index 0000000..28d0a94 --- /dev/null +++ b/w3t12.py @@ -0,0 +1,12 @@ +import turtle + +def arc(c): + for i in range(90): + turtle.forward(c) + turtle.right(2) + +turtle.shape('turtle') +turtle.left(90) +for i in range(5): + arc(2) + arc(0.5) \ No newline at end of file From 0f142d30910b07335daaf7049d863717f8a6f7e5 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 5 Oct 2019 21:04:34 +0300 Subject: [PATCH 14/41] week3 task13 --- w3t13.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 w3t13.py diff --git a/w3t13.py b/w3t13.py new file mode 100644 index 0000000..5a17107 --- /dev/null +++ b/w3t13.py @@ -0,0 +1,38 @@ +import turtle + +def arc(c): + for i in range(90): + turtle.forward(c) + turtle.right(2) + +def circle(c): + for i in range(180): + turtle.forward(c) + turtle.left(2) + +turtle.shape('turtle') +turtle.width(5) +turtle.begin_fill() +turtle.color('yellow') +circle(3) +turtle.end_fill() +turtle.left(90) +turtle.color('black') +turtle.penup() +turtle.goto(20,100) +turtle.pendown() +turtle.width(2) +arc(0.7) +turtle.left(180) +turtle.penup() +turtle.goto(-50,100) +turtle.pendown() +arc(0.7) +turtle.penup() +turtle.goto(30,50) +turtle.pendown() +turtle.begin_fill() +arc(1) +turtle.goto(30, 50) +turtle.end_fill() +#надеюсь со смайликом можно было пофантазировать? \ No newline at end of file From e595d2eb7e0d49f28d90d2af7fa9bfd1064ba42c Mon Sep 17 00:00:00 2001 From: polinapgv Date: Wed, 9 Oct 2019 09:39:51 +0300 Subject: [PATCH 15/41] week2 task5 edited --- t5.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/t5.py b/t5.py index b0e5541..22f8338 100644 --- a/t5.py +++ b/t5.py @@ -1,6 +1,7 @@ -import math n = int(input()) s = 0 +f = 1 for i in range(1, n + 1): - s += math.factorial(i) + f *= i + s += f print(s) \ No newline at end of file From e299c78bb0d60273f25e17ce6aadf7a626370c0a Mon Sep 17 00:00:00 2001 From: polinapgv Date: Wed, 9 Oct 2019 09:48:55 +0300 Subject: [PATCH 16/41] week2 task7 edited --- t7.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t7.py b/t7.py index a8c8c8e..6c8aa98 100644 --- a/t7.py +++ b/t7.py @@ -4,5 +4,5 @@ a.append(c) c = int(input()) for i in range(len(a)): - if i % 2 == 1: + if i % 2: print(a[i]) \ No newline at end of file From 19087dfff78433102ca899c40c7bb23745b91c3a Mon Sep 17 00:00:00 2001 From: polinapgv Date: Wed, 9 Oct 2019 09:52:36 +0300 Subject: [PATCH 17/41] week2 task8 edited --- t8.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t8.py b/t8.py index 9839262..d9a90bb 100644 --- a/t8.py +++ b/t8.py @@ -3,6 +3,6 @@ while c != 0: a.append(c) c = int(input()) -for i in range(len(a)): - if a[i] % 2 == 0: - print(a[i]) \ No newline at end of file +for elem in a: + if elem % 2 == 0: + print(elem) \ No newline at end of file From c125ebf482fe0a0fba8575bcf7881c83188cfaf0 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Wed, 9 Oct 2019 14:46:02 +0300 Subject: [PATCH 18/41] week3 task9 --- w3t9.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 w3t9.py diff --git a/w3t9.py b/w3t9.py new file mode 100644 index 0000000..590f2e3 --- /dev/null +++ b/w3t9.py @@ -0,0 +1,18 @@ +import turtle + +def polygon(n): + l = (15 + n * 5) + turtle.forward(l) + for i in range(n - 1): + turtle.left(360 / n) + turtle.forward(l) + +turtle.shape('turtle') +for i in range(3, 13): + angle = 90 - 180 / i + turtle.left(180 - angle) + polygon(i) + turtle.right(angle) + turtle.penup() + turtle.forward(10) + turtle.pendown() \ No newline at end of file From b06bb8d616d081fedbf5b8e2f223d24babd6f485 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Wed, 9 Oct 2019 14:51:10 +0300 Subject: [PATCH 19/41] week3 task14 5 pointed star --- w3t14_5.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 w3t14_5.py diff --git a/w3t14_5.py b/w3t14_5.py new file mode 100644 index 0000000..ef82ef2 --- /dev/null +++ b/w3t14_5.py @@ -0,0 +1,6 @@ +import turtle + +turtle.shape('turtle') +for i in range(5): + turtle.forward(100) + turtle.right(144) \ No newline at end of file From e9c55faabb2802b43acc74e4e96280dc45aa56cf Mon Sep 17 00:00:00 2001 From: polinapgv Date: Wed, 9 Oct 2019 15:07:37 +0300 Subject: [PATCH 20/41] week3 task14 11 pointed star --- w3t14_11.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 w3t14_11.py diff --git a/w3t14_11.py b/w3t14_11.py new file mode 100644 index 0000000..40c146e --- /dev/null +++ b/w3t14_11.py @@ -0,0 +1,6 @@ +import turtle + +turtle.shape('turtle') +for i in range(11): + turtle.forward(100) + turtle.left(163.636363) \ No newline at end of file From 375064af82987fb888828a8e2554afaa781a0032 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Fri, 11 Oct 2019 01:15:14 +0300 Subject: [PATCH 21/41] week4 tasks 1-5 --- w4t1.py | 10 ++++++++++ w4t2.py | 17 +++++++++++++++++ w4t3.py | 11 +++++++++++ w4t4.py | 14 ++++++++++++++ w4t5.py | 21 +++++++++++++++++++++ 5 files changed, 73 insertions(+) create mode 100644 w4t1.py create mode 100644 w4t2.py create mode 100644 w4t3.py create mode 100644 w4t4.py create mode 100644 w4t5.py diff --git a/w4t1.py b/w4t1.py new file mode 100644 index 0000000..4ac70f9 --- /dev/null +++ b/w4t1.py @@ -0,0 +1,10 @@ +a = [] +k = 0 +n = int(input()) +for i in range(n): + c = int(input()) + a.append(c) +for i in range(1, n - 1): + if a[i] > a[i - 1] and a[i] > a[i + 1]: + k += 1 +print(k) \ No newline at end of file diff --git a/w4t2.py b/w4t2.py new file mode 100644 index 0000000..24ef107 --- /dev/null +++ b/w4t2.py @@ -0,0 +1,17 @@ +n = int(input()) +a = [] +c = int(input()) +a.append(c) +minimum, maximum = c +max_i, min_i = 0 +for i in range(n - 1): + c = int(input()) + a.append(c) +for i in range(n): + if a[i] > maximum: + max_i = i + maximum = a[i] + elif a[i] < minimum: + min_i = i + minimum = a[i] +a[max_i], a[min_i] = a[min_i], a[max_i] \ No newline at end of file diff --git a/w4t3.py b/w4t3.py new file mode 100644 index 0000000..1e73b7d --- /dev/null +++ b/w4t3.py @@ -0,0 +1,11 @@ +n = int(input()) +a = [] +for i in range(n): + c = int(input()) + a.append(c) +k = 0 +for i in range(n): + for j in range(i + 1, n): + if a[i] == a[j]: + k += 1 +print(k) \ No newline at end of file diff --git a/w4t4.py b/w4t4.py new file mode 100644 index 0000000..dfc9bfa --- /dev/null +++ b/w4t4.py @@ -0,0 +1,14 @@ +n = int(input()) +a = [] +for i in range(n): + c = int(input()) + a.append(c) +f = 0 +for i in range(n): + for j in range(n): + if a[i] == a[j] and i != j: + f += 1 + if f == 0: + print(a[i]) + else: + f = 0 \ No newline at end of file diff --git a/w4t5.py b/w4t5.py new file mode 100644 index 0000000..7df4597 --- /dev/null +++ b/w4t5.py @@ -0,0 +1,21 @@ +a, b = [], [] +na = int(input()) +nb = int(input()) +for i in range(na): + c= int(input()) + a.append(c) +for i in range(nb): + c = int(input()) + b.append(c) +a_b = [] +for i in range(na): + for j in range(nb): + if a[i] == b[j]: + a_b.append(a[i]) +for i in range(len(a_b)): + for j in range(i, len(a_b)): + if a_b[i] > a_b[j]: + c = a_b[j] + a_b[j] = a_b[i] + a_b[i] = c +print(a_b) \ No newline at end of file From b0b1897339926543f2fdf60927b577e1b52a7939 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 12 Oct 2019 13:24:27 +0300 Subject: [PATCH 22/41] week4 tasks 6-9 + bonus --- w4t6.py | 12 ++++++++++++ w4t7.py | 17 +++++++++++++++++ w4t8.py | 12 ++++++++++++ w4t9.py | 25 +++++++++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 w4t6.py create mode 100644 w4t7.py create mode 100644 w4t8.py create mode 100644 w4t9.py diff --git a/w4t6.py b/w4t6.py new file mode 100644 index 0000000..6ea3720 --- /dev/null +++ b/w4t6.py @@ -0,0 +1,12 @@ +a = [] +s = list(map(int, input().split())) +f = 0 +for i in range(len(s)): + for j in range(i): + if s[i] == s[j]: + f = 1 + if f == 1: + print('YES') + else: + print('NO') + f = 0 \ No newline at end of file diff --git a/w4t7.py b/w4t7.py new file mode 100644 index 0000000..4148977 --- /dev/null +++ b/w4t7.py @@ -0,0 +1,17 @@ +n = int(input()) +n_general = 0 +s_general = [] +f, k = 0, 0 +for i in range(n): + s_current = list(map(str, input().split())) + n_current = len(s_current) + s_general.append(s_current) + for j in range(n_current): + for k in range(n_general + j): + if s_current[j] == s_general[k]: + f = 1 + if f == 0: + k += 1 + f = 0 + n_general += n_current +pritn(k) \ No newline at end of file diff --git a/w4t8.py b/w4t8.py new file mode 100644 index 0000000..338fdca --- /dev/null +++ b/w4t8.py @@ -0,0 +1,12 @@ +n = int(input()) +dict_syn = {} +for i in range(n): + s = list(map(str, input().split())) + dict_syn[s[0]] = s[1] +word = str(input()) +if dict_syn.get(word) != None: + print(dict_syn[word]) +else: + for key, value in dict_syn.items(): + if value == word: + print(key) \ No newline at end of file diff --git a/w4t9.py b/w4t9.py new file mode 100644 index 0000000..637f3f2 --- /dev/null +++ b/w4t9.py @@ -0,0 +1,25 @@ +n = int(input()) +amount = {} +text = [] +maximum = 0 +word_max = '' +for i in range(n): + s = list(map(str, input().split())) + for j in range(len(s)): + text.append(s[j]) +for i in range(len(text)): + if amount.get(text[i]) == None: + amount[text[i]] = 1 + else: + amount[text[i]] += 1 + if amount[text[i]] > maximum: + maximum = amount[text[i]] + word_max = text[i] + elif amount[text[i]] == maximum and text[i] < word_max: + maximum = amount[text[i]] + word_max = text[i] +print(amount) #бонусное задание посчитать сколько раз встречается каждое слово +for i in range(len(text)): + if text[i] == word_max: + print(text[i]) + break \ No newline at end of file From 9bb22a60cba3165bf66b00557a33bc8667166910 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 12 Oct 2019 15:37:57 +0300 Subject: [PATCH 23/41] week2 --- t1.py => week2/t1.py | 0 t2.py => week2/t2.py | 0 t3.py => week2/t3.py | 0 t4.py => week2/t4.py | 0 t5.py => week2/t5.py | 0 t6.py => week2/t6.py | 0 t7.py => week2/t7.py | 0 t8.py => week2/t8.py | 0 t9.py => week2/t9.py | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename t1.py => week2/t1.py (100%) rename t2.py => week2/t2.py (100%) rename t3.py => week2/t3.py (100%) rename t4.py => week2/t4.py (100%) rename t5.py => week2/t5.py (100%) rename t6.py => week2/t6.py (100%) rename t7.py => week2/t7.py (100%) rename t8.py => week2/t8.py (100%) rename t9.py => week2/t9.py (100%) diff --git a/t1.py b/week2/t1.py similarity index 100% rename from t1.py rename to week2/t1.py diff --git a/t2.py b/week2/t2.py similarity index 100% rename from t2.py rename to week2/t2.py diff --git a/t3.py b/week2/t3.py similarity index 100% rename from t3.py rename to week2/t3.py diff --git a/t4.py b/week2/t4.py similarity index 100% rename from t4.py rename to week2/t4.py diff --git a/t5.py b/week2/t5.py similarity index 100% rename from t5.py rename to week2/t5.py diff --git a/t6.py b/week2/t6.py similarity index 100% rename from t6.py rename to week2/t6.py diff --git a/t7.py b/week2/t7.py similarity index 100% rename from t7.py rename to week2/t7.py diff --git a/t8.py b/week2/t8.py similarity index 100% rename from t8.py rename to week2/t8.py diff --git a/t9.py b/week2/t9.py similarity index 100% rename from t9.py rename to week2/t9.py From b654014cba6683a67fc44d1c625ea6d8fe33503e Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 12 Oct 2019 15:38:26 +0300 Subject: [PATCH 24/41] week3 --- w03t2.py => week3/w03t2.py | 0 w3t10.py => week3/w3t10.py | 0 w3t11.py => week3/w3t11.py | 0 w3t12.py => week3/w3t12.py | 0 w3t13.py => week3/w3t13.py | 0 w3t14_11.py => week3/w3t14_11.py | 0 w3t14_5.py => week3/w3t14_5.py | 0 w3t3.py => week3/w3t3.py | 0 w3t4.py => week3/w3t4.py | 0 w3t5.py => week3/w3t5.py | 0 w3t6.py => week3/w3t6.py | 0 w3t7.py => week3/w3t7.py | 0 w3t8.py => week3/w3t8.py | 0 w3t9.py => week3/w3t9.py | 0 14 files changed, 0 insertions(+), 0 deletions(-) rename w03t2.py => week3/w03t2.py (100%) rename w3t10.py => week3/w3t10.py (100%) rename w3t11.py => week3/w3t11.py (100%) rename w3t12.py => week3/w3t12.py (100%) rename w3t13.py => week3/w3t13.py (100%) rename w3t14_11.py => week3/w3t14_11.py (100%) rename w3t14_5.py => week3/w3t14_5.py (100%) rename w3t3.py => week3/w3t3.py (100%) rename w3t4.py => week3/w3t4.py (100%) rename w3t5.py => week3/w3t5.py (100%) rename w3t6.py => week3/w3t6.py (100%) rename w3t7.py => week3/w3t7.py (100%) rename w3t8.py => week3/w3t8.py (100%) rename w3t9.py => week3/w3t9.py (100%) diff --git a/w03t2.py b/week3/w03t2.py similarity index 100% rename from w03t2.py rename to week3/w03t2.py diff --git a/w3t10.py b/week3/w3t10.py similarity index 100% rename from w3t10.py rename to week3/w3t10.py diff --git a/w3t11.py b/week3/w3t11.py similarity index 100% rename from w3t11.py rename to week3/w3t11.py diff --git a/w3t12.py b/week3/w3t12.py similarity index 100% rename from w3t12.py rename to week3/w3t12.py diff --git a/w3t13.py b/week3/w3t13.py similarity index 100% rename from w3t13.py rename to week3/w3t13.py diff --git a/w3t14_11.py b/week3/w3t14_11.py similarity index 100% rename from w3t14_11.py rename to week3/w3t14_11.py diff --git a/w3t14_5.py b/week3/w3t14_5.py similarity index 100% rename from w3t14_5.py rename to week3/w3t14_5.py diff --git a/w3t3.py b/week3/w3t3.py similarity index 100% rename from w3t3.py rename to week3/w3t3.py diff --git a/w3t4.py b/week3/w3t4.py similarity index 100% rename from w3t4.py rename to week3/w3t4.py diff --git a/w3t5.py b/week3/w3t5.py similarity index 100% rename from w3t5.py rename to week3/w3t5.py diff --git a/w3t6.py b/week3/w3t6.py similarity index 100% rename from w3t6.py rename to week3/w3t6.py diff --git a/w3t7.py b/week3/w3t7.py similarity index 100% rename from w3t7.py rename to week3/w3t7.py diff --git a/w3t8.py b/week3/w3t8.py similarity index 100% rename from w3t8.py rename to week3/w3t8.py diff --git a/w3t9.py b/week3/w3t9.py similarity index 100% rename from w3t9.py rename to week3/w3t9.py From c215be46e43104b020c0bad1335f6195b659a443 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 12 Oct 2019 15:38:43 +0300 Subject: [PATCH 25/41] week4 --- w4t1.py => week4/w4t1.py | 0 week4/w4t10.py | 2 ++ w4t2.py => week4/w4t2.py | 0 w4t3.py => week4/w4t3.py | 0 w4t4.py => week4/w4t4.py | 0 w4t5.py => week4/w4t5.py | 0 w4t6.py => week4/w4t6.py | 0 w4t7.py => week4/w4t7.py | 0 w4t8.py => week4/w4t8.py | 0 w4t9.py => week4/w4t9.py | 0 10 files changed, 2 insertions(+) rename w4t1.py => week4/w4t1.py (100%) create mode 100644 week4/w4t10.py rename w4t2.py => week4/w4t2.py (100%) rename w4t3.py => week4/w4t3.py (100%) rename w4t4.py => week4/w4t4.py (100%) rename w4t5.py => week4/w4t5.py (100%) rename w4t6.py => week4/w4t6.py (100%) rename w4t7.py => week4/w4t7.py (100%) rename w4t8.py => week4/w4t8.py (100%) rename w4t9.py => week4/w4t9.py (100%) diff --git a/w4t1.py b/week4/w4t1.py similarity index 100% rename from w4t1.py rename to week4/w4t1.py diff --git a/week4/w4t10.py b/week4/w4t10.py new file mode 100644 index 0000000..90d34e7 --- /dev/null +++ b/week4/w4t10.py @@ -0,0 +1,2 @@ +n = int(input()) +for i in range(n): diff --git a/w4t2.py b/week4/w4t2.py similarity index 100% rename from w4t2.py rename to week4/w4t2.py diff --git a/w4t3.py b/week4/w4t3.py similarity index 100% rename from w4t3.py rename to week4/w4t3.py diff --git a/w4t4.py b/week4/w4t4.py similarity index 100% rename from w4t4.py rename to week4/w4t4.py diff --git a/w4t5.py b/week4/w4t5.py similarity index 100% rename from w4t5.py rename to week4/w4t5.py diff --git a/w4t6.py b/week4/w4t6.py similarity index 100% rename from w4t6.py rename to week4/w4t6.py diff --git a/w4t7.py b/week4/w4t7.py similarity index 100% rename from w4t7.py rename to week4/w4t7.py diff --git a/w4t8.py b/week4/w4t8.py similarity index 100% rename from w4t8.py rename to week4/w4t8.py diff --git a/w4t9.py b/week4/w4t9.py similarity index 100% rename from w4t9.py rename to week4/w4t9.py From 030c0b939f122f53cb3d1c4fb58dc0344d86aeb0 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 12 Oct 2019 23:23:00 +0300 Subject: [PATCH 26/41] week4 tasks 7-9 edited --- week4/w4t7.py | 2 +- week4/w4t8.py | 2 +- week4/w4t9.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/week4/w4t7.py b/week4/w4t7.py index 4148977..c20b5be 100644 --- a/week4/w4t7.py +++ b/week4/w4t7.py @@ -14,4 +14,4 @@ k += 1 f = 0 n_general += n_current -pritn(k) \ No newline at end of file +print(k) \ No newline at end of file diff --git a/week4/w4t8.py b/week4/w4t8.py index 338fdca..72279d7 100644 --- a/week4/w4t8.py +++ b/week4/w4t8.py @@ -4,7 +4,7 @@ s = list(map(str, input().split())) dict_syn[s[0]] = s[1] word = str(input()) -if dict_syn.get(word) != None: +if dict_syn.get(word) is not None: print(dict_syn[word]) else: for key, value in dict_syn.items(): diff --git a/week4/w4t9.py b/week4/w4t9.py index 637f3f2..f669373 100644 --- a/week4/w4t9.py +++ b/week4/w4t9.py @@ -8,7 +8,7 @@ for j in range(len(s)): text.append(s[j]) for i in range(len(text)): - if amount.get(text[i]) == None: + if amount.get(text[i]) is None: amount[text[i]] = 1 else: amount[text[i]] += 1 @@ -18,7 +18,7 @@ elif amount[text[i]] == maximum and text[i] < word_max: maximum = amount[text[i]] word_max = text[i] -print(amount) #бонусное задание посчитать сколько раз встречается каждое слово +print(amount) #бонусное задание посчитать сколько раз встречается каждое слово for i in range(len(text)): if text[i] == word_max: print(text[i]) From 95d441fca172f62de388e49796d2abb92b370fd1 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 12 Oct 2019 23:31:11 +0300 Subject: [PATCH 27/41] week4 task10 --- week4/w4t10.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/week4/w4t10.py b/week4/w4t10.py index 90d34e7..0be37e4 100644 --- a/week4/w4t10.py +++ b/week4/w4t10.py @@ -1,2 +1,11 @@ n = int(input()) +summary = {} for i in range(n): + s = list(map(str, input().split())) + if summary.get(s[0]) is None: + summary[s[0]] = {} + if summary[s[0]].get(s[1]) is not None: + summary[s[0]][s[1]] += int(s[2]) + else: + summary[s[0]][s[1]] = int(s[2]) +print(summary) \ No newline at end of file From 79039cee44cdcb396f1d65a86814a4605892b7ce Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 19 Oct 2019 14:35:57 +0300 Subject: [PATCH 28/41] week3 task11 edited --- week3/w3t11.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/week3/w3t11.py b/week3/w3t11.py index 243b9e2..7e94ed7 100644 --- a/week3/w3t11.py +++ b/week3/w3t11.py @@ -1,19 +1,19 @@ import turtle -def circleleft(n): - for i in range(180): - turtle.forward(n) - turtle.left(2) - -def circleright(n): - for i in range(180): - turtle.forward(n) - turtle.right(2) +def circle(n, *, direction): + if direction == 'left': + for i in range(180): + turtle.forward(n) + turtle.left(2) + else: + for i in range(180): + turtle.forward(n) + turtle.right(2) turtle.shape('turtle') turtle.left(90) l = 0 for i in range(1, 11): l += 0.5 - circleleft(l) - circleright(l) \ No newline at end of file + circle(l, direction = 'left') + circle(l, direction = 'right') \ No newline at end of file From 4c2cab65e501435c455210ffa584e2291e764ef5 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 19 Oct 2019 14:37:07 +0300 Subject: [PATCH 29/41] week3 task11 edited --- week3/w3t11.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/week3/w3t11.py b/week3/w3t11.py index 7e94ed7..c8a78cb 100644 --- a/week3/w3t11.py +++ b/week3/w3t11.py @@ -12,8 +12,8 @@ def circle(n, *, direction): turtle.shape('turtle') turtle.left(90) -l = 0 +length = 0 for i in range(1, 11): l += 0.5 - circle(l, direction = 'left') - circle(l, direction = 'right') \ No newline at end of file + circle(length, direction = 'left') + circle(length, direction = 'right') \ No newline at end of file From 8555020ec1403a2ea8debeff7c57b4d413e752ba Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 19 Oct 2019 14:37:39 +0300 Subject: [PATCH 30/41] week3 task11 edited --- week3/w3t11.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week3/w3t11.py b/week3/w3t11.py index c8a78cb..de0a628 100644 --- a/week3/w3t11.py +++ b/week3/w3t11.py @@ -14,6 +14,6 @@ def circle(n, *, direction): turtle.left(90) length = 0 for i in range(1, 11): - l += 0.5 + length += 0.5 circle(length, direction = 'left') circle(length, direction = 'right') \ No newline at end of file From a1fa0bdca5fddc928fe924d76385f9c9db996f6a Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 19 Oct 2019 14:38:33 +0300 Subject: [PATCH 31/41] week4 task1 edited --- week4/w4t1.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/week4/w4t1.py b/week4/w4t1.py index 4ac70f9..552c9cd 100644 --- a/week4/w4t1.py +++ b/week4/w4t1.py @@ -2,8 +2,7 @@ k = 0 n = int(input()) for i in range(n): - c = int(input()) - a.append(c) + a.append(int(input())) for i in range(1, n - 1): if a[i] > a[i - 1] and a[i] > a[i + 1]: k += 1 From 1598a0660fe0c0f317f59b0dcbaf732ce2bfa9aa Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 19 Oct 2019 14:41:11 +0300 Subject: [PATCH 32/41] week4 task1 edited --- week4/w4t1.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/week4/w4t1.py b/week4/w4t1.py index 552c9cd..7f2997a 100644 --- a/week4/w4t1.py +++ b/week4/w4t1.py @@ -1,9 +1,9 @@ -a = [] -k = 0 -n = int(input()) -for i in range(n): - a.append(int(input())) -for i in range(1, n - 1): - if a[i] > a[i - 1] and a[i] > a[i + 1]: - k += 1 -print(k) \ No newline at end of file +arr = [] +amount = 0 +num = int(input()) +for i in range(num): + arr.append(int(input())) +for i in range(1, num - 1): + if arr[i] > arr[i - 1] and arr[i] > arr[i + 1]: + amount += 1 +print(amount) \ No newline at end of file From 95d63770b647725a21652bb305446a08505481bf Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 19 Oct 2019 14:42:19 +0300 Subject: [PATCH 33/41] week4 task10 edited --- week4/w4t10.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week4/w4t10.py b/week4/w4t10.py index 0be37e4..f12fda6 100644 --- a/week4/w4t10.py +++ b/week4/w4t10.py @@ -1,7 +1,7 @@ n = int(input()) summary = {} for i in range(n): - s = list(map(str, input().split())) + s = input().split() if summary.get(s[0]) is None: summary[s[0]] = {} if summary[s[0]].get(s[1]) is not None: From dba8792cfa00e840fa2b55d1b1bc4e8d08c43e1a Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 19 Oct 2019 16:07:11 +0300 Subject: [PATCH 34/41] week 5 tasks 1-5 --- week5/w5t1.py | 12 ++++++++++ week5/w5t2.py | 25 +++++++++++++++++++++ week5/w5t3.py | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ week5/w5t4.py | 19 ++++++++++++++++ week5/w5t5.py | 20 +++++++++++++++++ 5 files changed, 138 insertions(+) create mode 100644 week5/w5t1.py create mode 100644 week5/w5t2.py create mode 100644 week5/w5t3.py create mode 100644 week5/w5t4.py create mode 100644 week5/w5t5.py diff --git a/week5/w5t1.py b/week5/w5t1.py new file mode 100644 index 0000000..5c7bca0 --- /dev/null +++ b/week5/w5t1.py @@ -0,0 +1,12 @@ +def power(a, n): + a1 = 1 + if n > 0: + for i in range(n): + a1 *= a + elif n < 0: + for i in range(abs(n)): + a1 /= a + return(a1) + +a, n = map(int, input().split()) +print(power(a, n)) \ No newline at end of file diff --git a/week5/w5t2.py b/week5/w5t2.py new file mode 100644 index 0000000..2b36bcb --- /dev/null +++ b/week5/w5t2.py @@ -0,0 +1,25 @@ +def gcd(a,b): + if b == 0: + return(a) + else: + return(gcd(b, a % b)) + +print("Enter the amount of pairs of numbers") +n = int(input()) +print("Choose the way you want to receive answer:") +print("1. After every pair I've entered") +print("2. After all pairs I've entered") +print("Enter the number of the way you've chosen") +way = int(input()) +if way == 1: + for i in range(n): + a, b = map(int,input().split()) + print(gcd(a,b)) +elif way == 2: + pairs_gcd = [] + for i in range(n): + a, b = map(int, input().split()) + pairs_gcd.append(gcd(a,b)) + print(pairs_gcd) +else: + print("Wrong input, please try again") \ No newline at end of file diff --git a/week5/w5t3.py b/week5/w5t3.py new file mode 100644 index 0000000..525998e --- /dev/null +++ b/week5/w5t3.py @@ -0,0 +1,62 @@ +import math + +def circle(r): + return math.pi * r * r + +def triangle(*, height = None, side1 = None, side2 = None, side3 = None, angle = None): + if height == None: + if angle == None: + p = 0.5 * (side1 + side2 + side3) + return math.sqrt(p * (p - side1) * (p - side2) * (p - side3)) + else: + return side1 * side2 * 0.5 * math.sin(angle * math.pi / 180) + else: + return 0.5 * side1 * height +def rectangle(*, side1 = None, side2 = None, d1 = None, d2 = None, angle = None): + if angle == None: + return side1 * side2 + else: + return d1 * d2 * 0.5 * math.sin(angle * math.pi / 180) +print("Enter the shape type:") +shape = str(input()) +if shape == 'circle' or shape == 'Circle': + print('Enter the radius') + r = int(input()) + print(circle(r)) +elif shape == 'triangle' or shape == 'Triangle': + print("Choose the way you want to calculate the area:") + print("1. Side and its height") + print("2. Two sides and angle between them") + print("3. Three sides") + print("Enter the number of the way you've chosen") + way = int(input()) + if way == 1: + print( "Enter side and its height") + side, height = map(int, input().split()) + print(triangle(side1 = side, height = height)) + elif way == 2: + print("Enter two sides and angle between them") + side1, side2, angle = map(int, input().split()) + print(triangle(side1 = side1, side2 = side2, angle = angle)) + elif way == 3: + print("Enter three sides") + side1, side2, side3 = map(int, input().split()) + print(triangle(side1 =side1, side2 = side2, side3 = side3)) + else: + print("Wrong input, please try again") +elif shape == 'rectangle' or shape == 'Rectangle': + print("Choose the way you want to calculate the area:") + print("1. Two sides") + print("2. Two diagonals and angle between them") + print("Enter the number of the way you've chosen") + way = int(input()) + if way == 1: + print("Enter two sides") + side1, side2 = map(int, input().split()) + print(rectangle(side1 = side1, side2 = side2)) + elif way == 2: + print("Enter two diagonals and angle between them") + d1, d2, angle = map(int, input().split()) + print(rectangle(d1 = d1, d2 = d2, angle = angle)) +else: + print('Wrong type, please try again') \ No newline at end of file diff --git a/week5/w5t4.py b/week5/w5t4.py new file mode 100644 index 0000000..4d1bad5 --- /dev/null +++ b/week5/w5t4.py @@ -0,0 +1,19 @@ +print("Enter the amount of strings in your matrix") +n = int(input()) +print("Enter your matrix line by line") +matrix = [] +for i in range(n): + matrix.append(input().split()) +print("Enter the type of the diagonal you want to calculate") +diagonal = input() +summ = 0 +if diagonal == 'main' or diagonal == "Main": + for i in range(n): + summ += int(matrix[i][i]) + print(summ) +elif diagonal == 'side' or diagonal == "Side": + for i in range(n): + summ += int(matrix[i][n - i]) + print(summ) +else: + print("Wrong input, please try again") \ No newline at end of file diff --git a/week5/w5t5.py b/week5/w5t5.py new file mode 100644 index 0000000..ea21ab0 --- /dev/null +++ b/week5/w5t5.py @@ -0,0 +1,20 @@ +import matplotlib.pyplot as plt + +def f (x): + if x < -5: + return(2 * abs(x) - 1) + elif x > 5: + return(2 * x) + else: + return(x ** 2) + +x, y = [], [] +for i in range(21): + x.append(i - 10) +for elem in x: + y.append(f(elem)) +plt.plot(x, y) +plt.xlabel("x") +plt.ylabel("y") +plt.grid(True, alpha = 0.5) +plt.show() \ No newline at end of file From 4c94e2c6ca6a569c131a158fea613dbb55ea095b Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 19 Oct 2019 16:53:53 +0300 Subject: [PATCH 35/41] week4 task8 edited --- week4/w4t8.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/week4/w4t8.py b/week4/w4t8.py index 72279d7..b2c250d 100644 --- a/week4/w4t8.py +++ b/week4/w4t8.py @@ -1,12 +1,8 @@ n = int(input()) dict_syn = {} for i in range(n): - s = list(map(str, input().split())) - dict_syn[s[0]] = s[1] -word = str(input()) -if dict_syn.get(word) is not None: - print(dict_syn[word]) -else: - for key, value in dict_syn.items(): - if value == word: - print(key) \ No newline at end of file + word, synonym = input().split() + dict_syn[word] = synonym + dict_syn[synonym] = word +word_orig = str(input()) +print(dict_syn[word_orig]) \ No newline at end of file From ed52e63a61c6e6f36d415e300ff2925d3528afce Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sat, 19 Oct 2019 16:57:47 +0300 Subject: [PATCH 36/41] week4 task9 edited --- week4/w4t9.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/week4/w4t9.py b/week4/w4t9.py index f669373..661c112 100644 --- a/week4/w4t9.py +++ b/week4/w4t9.py @@ -4,9 +4,8 @@ maximum = 0 word_max = '' for i in range(n): - s = list(map(str, input().split())) - for j in range(len(s)): - text.append(s[j]) + s = input().split() + text += s for i in range(len(text)): if amount.get(text[i]) is None: amount[text[i]] = 1 From eb1f551e60b144682a8a387e82b1fbac0ab8d6bd Mon Sep 17 00:00:00 2001 From: polinapgv Date: Sun, 20 Oct 2019 23:15:06 +0300 Subject: [PATCH 37/41] week4 task4 edited --- week4/w4t4.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/week4/w4t4.py b/week4/w4t4.py index dfc9bfa..249d50a 100644 --- a/week4/w4t4.py +++ b/week4/w4t4.py @@ -1,14 +1,11 @@ n = int(input()) -a = [] +a = {} for i in range(n): - c = int(input()) - a.append(c) -f = 0 -for i in range(n): - for j in range(n): - if a[i] == a[j] and i != j: - f += 1 - if f == 0: - print(a[i]) + key = str(input()) + if key in a: + a[key] += 1 else: - f = 0 \ No newline at end of file + a[key] = 1 +for key in a: + if a[key] == 1: + print(key) \ No newline at end of file From b44fdd7795ed1a41955c7df37b10315fdb84f4f7 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Mon, 21 Oct 2019 17:18:21 +0300 Subject: [PATCH 38/41] week4 task5 edited --- week4/w4t5.py | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/week4/w4t5.py b/week4/w4t5.py index 7df4597..896a959 100644 --- a/week4/w4t5.py +++ b/week4/w4t5.py @@ -1,21 +1,13 @@ -a, b = [], [] -na = int(input()) -nb = int(input()) -for i in range(na): - c= int(input()) - a.append(c) -for i in range(nb): - c = int(input()) - b.append(c) -a_b = [] -for i in range(na): - for j in range(nb): - if a[i] == b[j]: - a_b.append(a[i]) -for i in range(len(a_b)): - for j in range(i, len(a_b)): - if a_b[i] > a_b[j]: - c = a_b[j] - a_b[j] = a_b[i] - a_b[i] = c -print(a_b) \ No newline at end of file +def sort(a): + for i in range(len(a)): + for j in range(i, len(a)): + if a[i] > a[j]: + c = a[i] + a[i] = a[j] + a[j] = c + return(a) + + +a = set(input().split()) +b = set(input().split()) +print(sort(list(a.intersection(b)))) \ No newline at end of file From aab98a4a35e36a8df4aaa386d64cd4781794169c Mon Sep 17 00:00:00 2001 From: polinapgv Date: Mon, 21 Oct 2019 17:25:36 +0300 Subject: [PATCH 39/41] week4 task6 edited --- week4/w4t6.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/week4/w4t6.py b/week4/w4t6.py index 6ea3720..5188fa0 100644 --- a/week4/w4t6.py +++ b/week4/w4t6.py @@ -1,12 +1,8 @@ -a = [] s = list(map(int, input().split())) -f = 0 -for i in range(len(s)): - for j in range(i): - if s[i] == s[j]: - f = 1 - if f == 1: +s1 = set() +for elem in s: + if elem in s1: print('YES') else: print('NO') - f = 0 \ No newline at end of file + s1.add(elem) \ No newline at end of file From 93a0d7d5eab575c1fc7fdeb6607d9ab4c63e2394 Mon Sep 17 00:00:00 2001 From: polinapgv Date: Mon, 21 Oct 2019 17:31:11 +0300 Subject: [PATCH 40/41] week4 task7 edited --- week4/w4t7.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/week4/w4t7.py b/week4/w4t7.py index c20b5be..f85a11f 100644 --- a/week4/w4t7.py +++ b/week4/w4t7.py @@ -1,17 +1,7 @@ n = int(input()) -n_general = 0 -s_general = [] -f, k = 0, 0 +text = set() for i in range(n): - s_current = list(map(str, input().split())) - n_current = len(s_current) - s_general.append(s_current) - for j in range(n_current): - for k in range(n_general + j): - if s_current[j] == s_general[k]: - f = 1 - if f == 0: - k += 1 - f = 0 - n_general += n_current -print(k) \ No newline at end of file + s = input().split() + for elem in s: + text.add(elem) +print(len(text)) \ No newline at end of file From 3768a6e867a93a173f6c552f88ded0303f8174fc Mon Sep 17 00:00:00 2001 From: polinapgv Date: Mon, 21 Oct 2019 17:51:04 +0300 Subject: [PATCH 41/41] week4 task10 edited --- week4/w4t10.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/week4/w4t10.py b/week4/w4t10.py index f12fda6..c00ef6c 100644 --- a/week4/w4t10.py +++ b/week4/w4t10.py @@ -1,11 +1,23 @@ +def sort(dictionary): + keys = list(dictionary.keys()) + dictionary_final = {} + keys.sort() + for key in keys: + dictionary_final[key] = dictionary[key] + return dictionary_final + + n = int(input()) summary = {} for i in range(n): - s = input().split() - if summary.get(s[0]) is None: - summary[s[0]] = {} - if summary[s[0]].get(s[1]) is not None: - summary[s[0]][s[1]] += int(s[2]) + customer, item, amount = input().split() + if summary.get(customer) is None: + summary[customer] = {} + if summary[customer].get(item) is not None: + summary[customer][item] += int(amount) else: - summary[s[0]][s[1]] = int(s[2]) -print(summary) \ No newline at end of file + summary[customer][item] = int(amount) +customers = list(summary.keys()) +for customer in customers: + print(customer) + print(sort(summary[customer])) \ No newline at end of file