-
Notifications
You must be signed in to change notification settings - Fork 0
hw 1 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
hw 1 #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # 1. Найти сумму и произведение цифр трехзначного числа, которое вводит пользователь. | ||
|
|
||
| num = input("Введите трехзначное число: ") | ||
|
|
||
| num1 = int(num[0]) | ||
| num2 = int(num[1]) | ||
| num3 = int(num[2]) | ||
|
|
||
| summa = num1 + num2 + num3 | ||
| product = num1 * num2 * num3 | ||
|
|
||
| print(f'Сумма: {summa}. Произведение: {product}') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # 5. Пользователь вводит две буквы. Определить, на каких местах алфавита они стоят и сколько между ними находится букв. | ||
| letters = input("Введите две строчные буквы английского алфавита: ") | ||
| letter1 = letters[0] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Между буквами |
||
|
|
||
| print(f'Порядковый номер буквы {letter1} - {ord_letter_1}.') | ||
| print(f'Порядковый номер буквы {letter2} - {ord_letter_2}.') | ||
| print(f'Расстояние между ними - {letters_between} букв') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # 6. Пользователь вводит номер буквы в алфавите. Определить, какая это буква. | ||
|
|
||
| ord_n = int(input("Введите порядковый номер буквы: ")) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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}') | ||
| 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: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Сочетание |
||
| if l1 != l2 and l2 != l3 and l3 != l1: | ||
| print('Треугольник разносторонний') | ||
| elif l1 == l2 and l2 == l3 and l3 == l1: | ||
| print('Треугольник равносторонний') | ||
| else: | ||
| print('Треугольник равнобедренный') | ||
| else: | ||
| print('Треугольник несуществует') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # 8. Определить, является ли год, который ввел пользователем, високосным или невисокосным. | ||
| year = int(input("Введите номер года: ")) | ||
|
|
||
| if (year % 4) == 0: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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('Год невисокосный') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # 9. Вводятся три разных числа. Найти, какое из них является средним (больше одного, но меньше другого). | ||
| print('Введите три разных числа') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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}') | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Всё же решили использовать индексы массива. Что ж, пусть будет так.
Но потерять стрелочки в блок-схеме - это очень плохо.