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
4 changes: 4 additions & 0 deletions gb-python-ls2-1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a = list(input('Write something:) '))
print(a)
for element in a:
print(type(element))
7 changes: 7 additions & 0 deletions gb-python-ls2-2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
a = list(input('Write something:) ').split())
print(a)

for i in range(1, len(a), 2):
a[i - 1], a[i] = a[i], a[i - 1]

print(a)
9 changes: 9 additions & 0 deletions gb-python-ls2-3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
l_seasons = ['зима', 'зима', 'весна', 'весна', 'весна', 'лето', 'лето', 'лето', 'осень', 'осень', 'осень', 'зима']
d_seasons = {1: 'зима', 2: 'зима', 3: 'весна', 4: 'весна', 5: 'весна', 6: 'лето', 7: 'лето', 8: 'лето', 9: 'осень',
10: 'осень', 11: 'осень', 12: 'зима'}
month = int(input('Enter the month number: '))
if month in d_seasons:
print(l_seasons[month - 1])
print(d_seasons[month])
elso:
print('Invalid value')
4 changes: 4 additions & 0 deletions gb-python-ls2-4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a = input('Enter few words separated by a space: ').split()

for i, word in enumerate(a,1):
print(f'{i} {word[:10]}')
8 changes: 8 additions & 0 deletions gb-python-ls2-5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
a = [1, 9, 9, 7, 2, 0, 0, 1]
new_num = int(input('Enter a new rating: '))
i = 0
for n in a:
if new_num <= n:
i += 1
a.insert(i, new_num)
print(a)
19 changes: 19 additions & 0 deletions gb-python-ls2-6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
i = 1
products = []
n = int(input('Enter the number of products: '))
for _ in range(n):
name = input('Enter the product name: ')
price = input('Enter the product price: ')
quantity = input('Enter the product quantity: ')
measure = input('Enter the units of measurement: ')
products.append((i, {'name': name, 'price': price, 'quantity': quantity, 'units': measure}))
i += 1
print(products)
products_dict = {'name': [], 'price': [], 'quantity': [], 'measure': []}
for product in products:
products_dict['name'].append(product[1]['name'])
products_dict['price'].append(product[1]['price'])
products_dict['quantity'].append(product[1]['quantity'])
if product[1]['units'] not in products_dict['units']:
products_dict['units'].append(product[1]['units'])
print(products_dict)