From feecc004ddb2544e8b387b7aa881cd951f5a3c4f Mon Sep 17 00:00:00 2001 From: user_2i Date: Mon, 15 Dec 2025 14:14:30 +0500 Subject: [PATCH] 20251215 2.3 --- lesson2.3_1.py | 7 +++++++ lesson2.3_10.py | 18 ++++++++++++++++++ lesson2.3_11.py | 9 +++++++++ lesson2.3_12.py | 10 ++++++++++ lesson2.3_13.py | 12 ++++++++++++ lesson2.3_14.py | 16 ++++++++++++++++ lesson2.3_15.py | 10 ++++++++++ lesson2.3_16.py | 14 ++++++++++++++ lesson2.3_17.py | 12 ++++++++++++ lesson2.3_18.py | 15 +++++++++++++++ lesson2.3_19.py | 14 ++++++++++++++ lesson2.3_2.py | 8 ++++++++ lesson2.3_20.py | 17 +++++++++++++++++ lesson2.3_3.py | 7 +++++++ lesson2.3_4.py | 10 ++++++++++ lesson2.3_5.py | 9 +++++++++ lesson2.3_6.py | 8 ++++++++ lesson2.3_7.py | 7 +++++++ lesson2.3_8.py | 7 +++++++ lesson2.3_9.py | 8 ++++++++ 20 files changed, 218 insertions(+) create mode 100644 lesson2.3_1.py create mode 100644 lesson2.3_10.py create mode 100644 lesson2.3_11.py create mode 100644 lesson2.3_12.py create mode 100644 lesson2.3_13.py create mode 100644 lesson2.3_14.py create mode 100644 lesson2.3_15.py create mode 100644 lesson2.3_16.py create mode 100644 lesson2.3_17.py create mode 100644 lesson2.3_18.py create mode 100644 lesson2.3_19.py create mode 100644 lesson2.3_2.py create mode 100644 lesson2.3_20.py create mode 100644 lesson2.3_3.py create mode 100644 lesson2.3_4.py create mode 100644 lesson2.3_5.py create mode 100644 lesson2.3_6.py create mode 100644 lesson2.3_7.py create mode 100644 lesson2.3_8.py create mode 100644 lesson2.3_9.py diff --git a/lesson2.3_1.py b/lesson2.3_1.py new file mode 100644 index 0000000..3c9d697 --- /dev/null +++ b/lesson2.3_1.py @@ -0,0 +1,7 @@ +'''****** Задание ******** + *Раз, два, три! Ёлочка, гори! +''' +while (s := input()) != 'Три!': + print('Режим ожидания...') +else: + print('Ёлочка, гори!') \ No newline at end of file diff --git a/lesson2.3_10.py b/lesson2.3_10.py new file mode 100644 index 0000000..7d8ef79 --- /dev/null +++ b/lesson2.3_10.py @@ -0,0 +1,18 @@ +'''****** Задание ******** + *Маршрут построен. +''' +a = 0 +b = 0 +while (dir := input()) != 'СТОП': + steps = int(input()) + match dir: + case 'СЕВЕР': + a += steps + case 'ЮГ': + a -= steps + case 'ЗАПАД': + b -= steps + case 'ВОСТОК': + b += steps +print(a) +print(b) \ No newline at end of file diff --git a/lesson2.3_11.py b/lesson2.3_11.py new file mode 100644 index 0000000..536ef1c --- /dev/null +++ b/lesson2.3_11.py @@ -0,0 +1,9 @@ +'''****** Задание ******** + *Цифровая сумма. +''' +num = int(input()) +summa = 0 +while num > 0: + summa += num % 10 # s = s + num % 10 + num //= 10 # num = num // 10 +print(summa) \ No newline at end of file diff --git a/lesson2.3_12.py b/lesson2.3_12.py new file mode 100644 index 0000000..3f8e1a5 --- /dev/null +++ b/lesson2.3_12.py @@ -0,0 +1,10 @@ +'''****** Задание ******** + *Сильная цифра. +''' +num = int(input()) +maximum = -1 +while num > 0: + if num % 10 > maximum: + maximum = num % 10 + num = num // 10 +print(maximum) \ No newline at end of file diff --git a/lesson2.3_13.py b/lesson2.3_13.py new file mode 100644 index 0000000..5953ca4 --- /dev/null +++ b/lesson2.3_13.py @@ -0,0 +1,12 @@ +'''****** Задание ******** + *Первому игроку приготовиться 2.0. +''' +count = int(input()) +first = '' +for _ in range(count): + name = input() + if first == '': + first = name + elif name < first: + first = name +print(first) \ No newline at end of file diff --git a/lesson2.3_14.py b/lesson2.3_14.py new file mode 100644 index 0000000..250e68d --- /dev/null +++ b/lesson2.3_14.py @@ -0,0 +1,16 @@ +'''****** Задание ******** + *Простая задача. +''' +num = int(input()) +prime = True +if num <= 1: + prime = False +else: + for divisor in range(2, int(num**0.5 + 1)): + if num % divisor == 0: + prime = False + break +if prime is True: + print('YES') +else: + print('NO') \ No newline at end of file diff --git a/lesson2.3_15.py b/lesson2.3_15.py new file mode 100644 index 0000000..aa99557 --- /dev/null +++ b/lesson2.3_15.py @@ -0,0 +1,10 @@ +'''****** Задание ******** + *Зайка - 4. +''' +places = int(input()) +N = 0 +for i in range(places): + nature = input() + if 'зайка' in nature: + N += 1 +print(N) \ No newline at end of file diff --git a/lesson2.3_16.py b/lesson2.3_16.py new file mode 100644 index 0000000..35e8ae4 --- /dev/null +++ b/lesson2.3_16.py @@ -0,0 +1,14 @@ +'''****** Задание ******** + *А роза упала на лапу Азора 2.0. +''' +num = int(input()) +original_num = num +reversed_num = 0 +while num > 0: + digit = num % 10 + reversed_num = reversed_num * 10 + digit + num //= 10 +if original_num == reversed_num: + print('YES') +else: + print('NO') \ No newline at end of file diff --git a/lesson2.3_17.py b/lesson2.3_17.py new file mode 100644 index 0000000..1ad37d0 --- /dev/null +++ b/lesson2.3_17.py @@ -0,0 +1,12 @@ +'''****** Задание ******** + *Чётная чистота. +''' +number = int(input()) +result = 0 +power = 1 +while number > 0: + if number % 2 != 0: + result += (number % 10) * power + power *= 10 + number //= 10 +print(result) \ No newline at end of file diff --git a/lesson2.3_18.py b/lesson2.3_18.py new file mode 100644 index 0000000..80c63b7 --- /dev/null +++ b/lesson2.3_18.py @@ -0,0 +1,15 @@ +'''****** Задание ******** + *Простая задача 2.0. +''' +number = int(input()) +divisor = 1 +if number < 2: + print(number) +while number > 1: + divisor += 1 + if not number % divisor: + print(divisor, end='') + if number != divisor: + print(' *', end=' ') + number //= divisor + divisor = 1 \ No newline at end of file diff --git a/lesson2.3_19.py b/lesson2.3_19.py new file mode 100644 index 0000000..582c48e --- /dev/null +++ b/lesson2.3_19.py @@ -0,0 +1,14 @@ +'''****** Задание ******** + *Игра в «Угадайку». +''' +number = 500 +delta = number // 2 +print(number) +while (answer := input()) != 'Угадал!': + if answer == 'Меньше': + number = number - delta + if answer == 'Больше': + number = number + delta + if delta >= 2: + delta = (delta + 1) // 2 + print(number) \ No newline at end of file diff --git a/lesson2.3_2.py b/lesson2.3_2.py new file mode 100644 index 0000000..fdd81aa --- /dev/null +++ b/lesson2.3_2.py @@ -0,0 +1,8 @@ +'''****** Задание ******** + *Зайка — 3. +''' +count = 0 +while (s := input()) != 'Приехали!': + if 'зайка' in s: + count += 1 +print(count) \ No newline at end of file diff --git a/lesson2.3_20.py b/lesson2.3_20.py new file mode 100644 index 0000000..eb79dfc --- /dev/null +++ b/lesson2.3_20.py @@ -0,0 +1,17 @@ +'''****** Задание ******** + *Хайпанём немножечко! +''' +n = int(input()) +num_false_h = -1 +pre_h = 0 +for i in range(n): + block = int(input()) + h = block % 256 + m = block // 256 ** 2 + r = (block // 256) % 256 + true_h = (37 * (m + r + pre_h)) % 256 + pre_h = h + if true_h >= 100 or true_h != h: + num_false_h = i + break +print(num_false_h) \ No newline at end of file diff --git a/lesson2.3_3.py b/lesson2.3_3.py new file mode 100644 index 0000000..b04a464 --- /dev/null +++ b/lesson2.3_3.py @@ -0,0 +1,7 @@ +'''****** Задание ******** + *Считалочка. +''' +start = int(input()) +finish = int(input()) +for i in range(start, finish + 1): + print(i, end=' ') \ No newline at end of file diff --git a/lesson2.3_4.py b/lesson2.3_4.py new file mode 100644 index 0000000..cd8e431 --- /dev/null +++ b/lesson2.3_4.py @@ -0,0 +1,10 @@ +'''****** Задание ******** + *Считалочка 2.0. +''' +start = int(input()) +stop = int(input()) +step = 1 +if stop < start: + step = -1 +for i in range(start, stop + step, step): + print(i, end=' ') \ No newline at end of file diff --git a/lesson2.3_5.py b/lesson2.3_5.py new file mode 100644 index 0000000..1186650 --- /dev/null +++ b/lesson2.3_5.py @@ -0,0 +1,9 @@ +'''****** Задание ******** + *Внимание! Акция! +''' +result = 0 +while (price := float(input())) != 0: + if price >= 500: + price *= 0.9 + result += price +print(result) \ No newline at end of file diff --git a/lesson2.3_6.py b/lesson2.3_6.py new file mode 100644 index 0000000..388f9e8 --- /dev/null +++ b/lesson2.3_6.py @@ -0,0 +1,8 @@ +'''****** Задание ******** + *НОД. +''' +a = int(input()) +b = int(input()) +while a != 0: + a, b = b % a, a +print(b) \ No newline at end of file diff --git a/lesson2.3_7.py b/lesson2.3_7.py new file mode 100644 index 0000000..99bcf04 --- /dev/null +++ b/lesson2.3_7.py @@ -0,0 +1,7 @@ +'''****** Задание ******** + *НОК. +''' +a, b = a1, b1 = int(input()), int(input()) +while a != 0: + a, b = b % a, a +print(a1 * b1 // (a + b)) \ No newline at end of file diff --git a/lesson2.3_8.py b/lesson2.3_8.py new file mode 100644 index 0000000..6308464 --- /dev/null +++ b/lesson2.3_8.py @@ -0,0 +1,7 @@ +'''****** Задание ******** + *Излишняя автоматизация 2.0. +''' +info = input() +repeat = int(input()) +for _ in range(repeat): + print(info) \ No newline at end of file diff --git a/lesson2.3_9.py b/lesson2.3_9.py new file mode 100644 index 0000000..7afbe19 --- /dev/null +++ b/lesson2.3_9.py @@ -0,0 +1,8 @@ +'''****** Задание ******** + *Факториал. +''' +num = int(input()) +result = 1 +for n in range(1, num + 1): + result *= n +print(result) \ No newline at end of file