-
Notifications
You must be signed in to change notification settings - Fork 337
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
Урок 2 #1800
base: master
Are you sure you want to change the base?
The head ref may contain hidden characters: "\u0423\u0440\u043E\u043A_2"
Урок 2 #1800
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 |
---|---|---|
|
@@ -15,3 +15,8 @@ | |
<class 'bool'> | ||
<class 'NoneType'> | ||
""" | ||
|
||
a = [5, "string", 0.15, True, None] | ||
|
||
for el in a: | ||
print(type(el)) | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,14 @@ | |
Введите целые числа через пробел: 1 2 3 | ||
Результат: 2 1 3 | ||
""" | ||
|
||
user_input_list = list(input("Введите значения: ").split()) | ||
|
||
user_list = [] | ||
|
||
for i in range(0, len(user_input_list), 2): | ||
j = i + 2 | ||
a = user_input_list[i:j] | ||
a.reverse() | ||
user_list.extend(a) | ||
print(user_list) | ||
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. выполнено |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,44 @@ | |
Результат через список: Осень | ||
Результат через словарь: Осень | ||
""" | ||
|
||
""" | ||
Вариант 1 | ||
""" | ||
print("\nВариант 1: list.\n") | ||
|
||
month_name_lst = ["Зима", "Весна", "Лето", "Осень"] | ||
|
||
input_month_lst = int(input("Введите номер месяца:")) | ||
|
||
if input_month_lst == 1 or input_month_lst == 2 or input_month_lst == 12: | ||
print(month_name_lst[0]) | ||
if input_month_lst == 3 or input_month_lst == 4 or input_month_lst == 5: | ||
print(month_name_lst[1]) | ||
if input_month_lst == 6 or input_month_lst == 7 or input_month_lst == 8: | ||
print(month_name_lst[2]) | ||
if input_month_lst == 9 or input_month_lst == 10 or input_month_lst == 11: | ||
print(month_name_lst[3]) | ||
if input_month_lst <= 0 or input_month_lst >= 13: | ||
print("\nТакого номера месяца нет.Введите число от 1 до 12.\n") | ||
|
||
""" | ||
Вариант 2 | ||
""" | ||
print("\nВариант 2: dict.\n") | ||
|
||
season_dict = { | ||
"Зима": [12,1,2], | ||
"Весна": [3,4,5], | ||
"Лето": [6,7,8], | ||
"Осень": [9,10,11] | ||
} | ||
|
||
input_month_dict = int(input("Введите номер месяца:")) | ||
|
||
for key, value in season_dict.items(): | ||
if input_month_dict in value: | ||
print(key) | ||
break | ||
else: | ||
print("\nТакого номера месяца нет.Введите число от 1 до 12.\n") | ||
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. выполнено |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,8 @@ | |
1. раз | ||
2. перерефриж | ||
""" | ||
|
||
user_input_list = input("Введите несколько слов через пробел: ").split() | ||
|
||
for i, el in enumerate(user_input, 1): | ||
print(i, el[0:10]) | ||
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. выполнено |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,12 @@ | |
Набор натуральных чисел можно задать непосредственно в коде, | ||
например, my_list = [7, 5, 3, 3, 2]. | ||
""" | ||
|
||
my_list = [7, 5, 3, 3, 2] | ||
|
||
user_input = int(input('Введите целое, положительное число: ')) | ||
|
||
my_list.append(user_input) | ||
my_list.sort(reverse=True) | ||
|
||
print(f'Рейтинг: {my_list}') | ||
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. выполнено |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,45 @@ | |
“ед”: [“шт.”] | ||
} | ||
""" | ||
|
||
goods = [] | ||
goods_num = 1 | ||
|
||
anal_dic = { | ||
"Наименование:": [], | ||
"Цена:": [], | ||
"Количество:": [], | ||
"Ед. измерения:": [] | ||
} | ||
|
||
while True: | ||
input_name = input("Введите наименование товара: ") | ||
input_price = float(input("Введите цену товара: ")) | ||
input_quantity = int(input("Введите количество товара: ")) | ||
input_unit = input("Введите еденицу измерения товара: ") | ||
|
||
summary_input = { | ||
"Наименование:": input_name, | ||
"Цена:": input_price, | ||
"Количество:": input_quantity, | ||
"Ед. измерения:": input_unit | ||
} | ||
|
||
summary_goods = (goods_num, summary_input) | ||
goods.append(summary_goods) | ||
|
||
for key, value in summary_input.items(): | ||
i = anal_dic.get(key) | ||
if value in i: | ||
continue | ||
i.append(value) | ||
continue | ||
|
||
goods_num += 1 | ||
|
||
question_for_exit = input("Закончить ввод?\n").lower() | ||
if question_for_exit == "да": | ||
print("\n",goods) | ||
break | ||
|
||
print("\n",goods) | ||
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. выполнено |
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.
выполнено