Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions task_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 1. Найти сумму и произведение цифр трехзначного числа, которое вводит пользователь.

num = input("Введите трехзначное число: ")

num1 = int(num[0])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Всё же решили использовать индексы массива. Что ж, пусть будет так.
Но потерять стрелочки в блок-схеме - это очень плохо.

num2 = int(num[1])
num3 = int(num[2])

summa = num1 + num2 + num3
product = num1 * num2 * num3

print(f'Сумма: {summa}. Произведение: {product}')
15 changes: 15 additions & 0 deletions task_5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 5. Пользователь вводит две буквы. Определить, на каких местах алфавита они стоят и сколько между ними находится букв.
letters = input("Введите две строчные буквы английского алфавита: ")
letter1 = letters[0]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И снова массив )))

letter2 = letters[1]

ord_a = ord("a")

ord_letter_1 = ord(letter1) - ord_a + 1
ord_letter_2 = ord(letter2) - ord_a + 1

letters_between = abs(ord_letter_2 - ord_letter_1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Между буквами a и d находятся b и c - две буквы. А у вас почему-то три.


print(f'Порядковый номер буквы {letter1} - {ord_letter_1}.')
print(f'Порядковый номер буквы {letter2} - {ord_letter_2}.')
print(f'Расстояние между ними - {letters_between} букв')
12 changes: 12 additions & 0 deletions task_6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 6. Пользователь вводит номер буквы в алфавите. Определить, какая это буква.

ord_n = int(input("Введите порядковый номер буквы: "))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отлично


if ord_n > 26:
print(f'Буква не может быть найдена')

else:
ord_a = ord("a")
letter = chr(ord_a + ord_n - 1)

print(f'Буква {letter}')
18 changes: 18 additions & 0 deletions task_7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 7. По длинам трех отрезков, введенных пользователем, определить возможность существования треугольника,
# составленного из этих отрезков. Если такой треугольник существует, то определить, является ли он разносторонним,
# равнобедренным или равносторонним.

print('Введите длины трех отрезков')
l1 = int(input('Введите длину первого отрезка: '))
l2 = int(input('Введите длину второго отрезка: '))
l3 = int(input('Введите длину третьего отрезка: '))

if l1 != 0 and l2 != 0 and l3 != 0 and (l1 + l2) > l3 and (l2 + l3) > l1 and (l3 + l1) > l2:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сочетание l и !. У вас в глазах не пестрит? Блок-схему еле осилил прочитать )))

if l1 != l2 and l2 != l3 and l3 != l1:
print('Треугольник разносторонний')
elif l1 == l2 and l2 == l3 and l3 == l1:
print('Треугольник равносторонний')
else:
print('Треугольник равнобедренный')
else:
print('Треугольник несуществует')
13 changes: 13 additions & 0 deletions task_8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 8. Определить, является ли год, который ввел пользователем, високосным или невисокосным.
year = int(input("Введите номер года: "))

if (year % 4) == 0:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отлично.
Кстати, скобочки в условиях можно не писать )))

if (year % 100) == 0:
if (year % 400) == 0:
print('Год високосный')
else:
print('Год невисокосный')
else:
print('Год високосный')
else:
print('Год невисокосный')
21 changes: 21 additions & 0 deletions task_9.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 9. Вводятся три разных числа. Найти, какое из них является средним (больше одного, но меньше другого).
print('Введите три разных числа')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отлично

num1 = int(input('Введите первое число: '))
num2 = int(input('Введите второе число: '))
num3 = int(input('Введите третье число: '))

if num1 > num2:
b1 = num1
b2 = num2
else:
b1 = num2
b2 = num1

if b2 > num3:
middle = b2
elif b1 > num3:
middle = num3
else:
middle = b1

print(f'Среднее число: {middle}')