From 3cb6de8ea7318755b78979d2939789be1012b1f0 Mon Sep 17 00:00:00 2001 From: anbryyy <99951461+anbryyy@users.noreply.github.com> Date: Thu, 24 Feb 2022 21:23:27 +0300 Subject: [PATCH 1/3] Add files via upload --- gb-python-ls2-1.py | 4 ++++ gb-python-ls2-2.py | 7 +++++++ gb-python-ls2-3.py | 7 +++++++ 3 files changed, 18 insertions(+) create mode 100644 gb-python-ls2-1.py create mode 100644 gb-python-ls2-2.py create mode 100644 gb-python-ls2-3.py diff --git a/gb-python-ls2-1.py b/gb-python-ls2-1.py new file mode 100644 index 0000000..b0bd152 --- /dev/null +++ b/gb-python-ls2-1.py @@ -0,0 +1,4 @@ +a = list(input('Write something:) ')) +print(a) +for element in a: + print(type(element)) \ No newline at end of file diff --git a/gb-python-ls2-2.py b/gb-python-ls2-2.py new file mode 100644 index 0000000..027fa3c --- /dev/null +++ b/gb-python-ls2-2.py @@ -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) \ No newline at end of file diff --git a/gb-python-ls2-3.py b/gb-python-ls2-3.py new file mode 100644 index 0000000..5391710 --- /dev/null +++ b/gb-python-ls2-3.py @@ -0,0 +1,7 @@ +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]) \ No newline at end of file From 5ccf0bfdc0a1fab47c8a7d11ecc4f76301282827 Mon Sep 17 00:00:00 2001 From: anbryyy <99951461+anbryyy@users.noreply.github.com> Date: Fri, 25 Feb 2022 08:52:31 +0300 Subject: [PATCH 2/3] Update gb-python-ls2-3.py --- gb-python-ls2-3.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gb-python-ls2-3.py b/gb-python-ls2-3.py index 5391710..f5d34ba 100644 --- a/gb-python-ls2-3.py +++ b/gb-python-ls2-3.py @@ -4,4 +4,6 @@ month = int(input('Enter the month number: ')) if month in d_seasons: print(l_seasons[month - 1]) - print(d_seasons[month]) \ No newline at end of file + print(d_seasons[month]) +elso: + print('Invalid value') From a92ffbebf11cbe2b57f822c6e47646ad0b6f74c7 Mon Sep 17 00:00:00 2001 From: anbryyy <99951461+anbryyy@users.noreply.github.com> Date: Fri, 25 Feb 2022 10:36:20 +0300 Subject: [PATCH 3/3] Add files via upload --- gb-python-ls2-4.py | 4 ++++ gb-python-ls2-5.py | 8 ++++++++ gb-python-ls2-6.py | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 gb-python-ls2-4.py create mode 100644 gb-python-ls2-5.py create mode 100644 gb-python-ls2-6.py diff --git a/gb-python-ls2-4.py b/gb-python-ls2-4.py new file mode 100644 index 0000000..86fee9e --- /dev/null +++ b/gb-python-ls2-4.py @@ -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]}') \ No newline at end of file diff --git a/gb-python-ls2-5.py b/gb-python-ls2-5.py new file mode 100644 index 0000000..292c793 --- /dev/null +++ b/gb-python-ls2-5.py @@ -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) \ No newline at end of file diff --git a/gb-python-ls2-6.py b/gb-python-ls2-6.py new file mode 100644 index 0000000..54ea542 --- /dev/null +++ b/gb-python-ls2-6.py @@ -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) \ No newline at end of file