20251215 2.3

This commit is contained in:
user_2i 2025-12-15 14:14:30 +05:00
parent e0521f3624
commit feecc004dd
20 changed files with 218 additions and 0 deletions

7
lesson2.3_1.py Normal file
View file

@ -0,0 +1,7 @@
'''****** Задание ********
*Раз, два, три! Ёлочка, гори!
'''
while (s := input()) != 'Три!':
print('Режим ожидания...')
else:
print('Ёлочка, гори!')

18
lesson2.3_10.py Normal file
View file

@ -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)

9
lesson2.3_11.py Normal file
View file

@ -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)

10
lesson2.3_12.py Normal file
View file

@ -0,0 +1,10 @@
'''****** Задание ********
*Сильная цифра.
'''
num = int(input())
maximum = -1
while num > 0:
if num % 10 > maximum:
maximum = num % 10
num = num // 10
print(maximum)

12
lesson2.3_13.py Normal file
View file

@ -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)

16
lesson2.3_14.py Normal file
View file

@ -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')

10
lesson2.3_15.py Normal file
View file

@ -0,0 +1,10 @@
'''****** Задание ********
*Зайка - 4.
'''
places = int(input())
N = 0
for i in range(places):
nature = input()
if 'зайка' in nature:
N += 1
print(N)

14
lesson2.3_16.py Normal file
View file

@ -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')

12
lesson2.3_17.py Normal file
View file

@ -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)

15
lesson2.3_18.py Normal file
View file

@ -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

14
lesson2.3_19.py Normal file
View file

@ -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)

8
lesson2.3_2.py Normal file
View file

@ -0,0 +1,8 @@
'''****** Задание ********
*Зайка — 3.
'''
count = 0
while (s := input()) != 'Приехали!':
if 'зайка' in s:
count += 1
print(count)

17
lesson2.3_20.py Normal file
View file

@ -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)

7
lesson2.3_3.py Normal file
View file

@ -0,0 +1,7 @@
'''****** Задание ********
*Считалочка.
'''
start = int(input())
finish = int(input())
for i in range(start, finish + 1):
print(i, end=' ')

10
lesson2.3_4.py Normal file
View file

@ -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=' ')

9
lesson2.3_5.py Normal file
View file

@ -0,0 +1,9 @@
'''****** Задание ********
*Внимание! Акция!
'''
result = 0
while (price := float(input())) != 0:
if price >= 500:
price *= 0.9
result += price
print(result)

8
lesson2.3_6.py Normal file
View file

@ -0,0 +1,8 @@
'''****** Задание ********
*НОД.
'''
a = int(input())
b = int(input())
while a != 0:
a, b = b % a, a
print(b)

7
lesson2.3_7.py Normal file
View file

@ -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))

7
lesson2.3_8.py Normal file
View file

@ -0,0 +1,7 @@
'''****** Задание ********
*Излишняя автоматизация 2.0.
'''
info = input()
repeat = int(input())
for _ in range(repeat):
print(info)

8
lesson2.3_9.py Normal file
View file

@ -0,0 +1,8 @@
'''****** Задание ********
*Факториал.
'''
num = int(input())
result = 1
for n in range(1, num + 1):
result *= n
print(result)