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
5 changes: 5 additions & 0 deletions task_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
my_list = [10, 67.2, 'string', True]

for item in my_list:
print(type(item))

11 changes: 11 additions & 0 deletions task_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
txt_input = input("Перечислите элементы списка через запятую (1,2,3): ")
arr_input = txt_input.split(",")

length = len(arr_input)
for key, item in enumerate(arr_input):
if key % 2 == 0 and key + 1 < length:
save = item
arr_input[key] = arr_input[key + 1]
arr_input[key + 1] = save

print(arr_input)
31 changes: 31 additions & 0 deletions task_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
month = int(input("Введите число месяца: "))

if month == 0 or month > 12:
print("Неверный формат месяца")
else:
# list
winter = [12, 1, 2]
spring = [3, 4, 5]
summer = [6, 7, 8]
autumn = [9, 10, 11]

if month in winter:
print("Это зима, бро")
if month in spring:
print("Это весна, бро")
if month in summer:
print("Это лето, бро")
if month in autumn:
print("Это осень, бро")

# dict
month_data = {
'зима': [12, 1, 2],
'весна': [3, 4, 5],
'лето': [6, 7, 8],
'осень': [9, 10, 11]
}
for m_key in month_data:
if month in month_data[m_key]:
print(f"Это {m_key}, бро")
break
9 changes: 9 additions & 0 deletions task_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
my_str = input("Введите предложение: ")
words = my_str.split(" ")

i = 1
for word in words:
if len(word) > 10:
word = word[:10]
print(f"{i}: {word}")
i += 1
16 changes: 16 additions & 0 deletions task_5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
i_num = int(input("Введите число рейтинга: "))
my_list = [7, 5, 3, 3, 2]

i = 0
update = False
for item in my_list:
if i_num >= item:
my_list.insert(i, i_num)
update = True
break
i += 1

if not update:
my_list.append(i_num)

print(my_list)
33 changes: 33 additions & 0 deletions task_6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
products = []

while True:
p_name = input("Введите название товара: ")
p_cost = input("Введите цену товара: ")
p_count = input("Введите количество товара: ")
p_it = input("Введите единицу измерения товара: ")
product = {
'название': p_name,
'цена': p_cost,
'количество': p_count,
'ед': p_it,
}
product_id = len(products) + 1
product_item = (product_id, product)
products.append(product_item)
print(products)

# аналитика
a_names = set()
a_costs = set()
a_counts = set()
a_it = set()
for item in products:
a_names.add(item[1]['название'])
a_costs.add(item[1]['цена'])
a_counts.add(item[1]['количество'])
a_it.add(item[1]['ед'])

print(a_names)
print(a_costs)
print(a_counts)
print(a_it)