Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 1
- students = input().split()
- students_dict = {}
- for i in range(0, len(students), 2):
- student = students[i]
- number = int(students[i+1])
- students_dict[student] = number
- print(students_dict)
- # 2
- products = input().split()
- order = input().split()
- products_storage = {}
- for i in range(0, len(products), 2):
- product = products[i]
- quantity = int(products[i + 1])
- if product not in products_storage:
- products_storage[product] = quantity
- else:
- products_storage[product] += quantity
- for item in range(0, len(order)):
- ordered_item = order[item]
- if ordered_item in products_storage:
- print(f'We have {products_storage[ordered_item]} of {ordered_item} left')
- else:
- print(f'Sorry, we dont have {ordered_item}')
- # 3
- products_stock = {}
- while True:
- command = input()
- if command == 'START':
- break
- else:
- product, quantity = command.split(': ')
- quantity = int(quantity)
- if product not in products_stock:
- products_stock[product] = quantity
- else:
- products_stock[product] += quantity
- total_products = len(products_stock)
- total_quantity = sum(products_stock.values())
- print('Products in stock: ')
- for key in products_stock:
- print(f'- {key}: {products_stock[key]}')
- print(f'Total Products: {total_products}')
- print(f'Total Quantity: {total_quantity}')
- # 4
- student_dict = {'I-ви курс': [], 'II-ри курс': [], 'III-ти курс': [], 'IV-ти курс': [], 'V-ти курс': []}
- while True:
- command = input()
- if command in student_dict.keys():
- final_command = command
- break
- else:
- name, number, course = command.split(':')
- student_dict[course].append((name, number))
- for student in student_dict[final_command]:
- print(f"{student[0]} - {student[1]}")
- # 5
- ascii_dict = {}
- ascii_input = input().split(', ')
- for item in ascii_input:
- ascii_dict[item] = ord(item)
- print(ascii_dict)
- # 6
- words = input().split()
- lower_words_dict = {}
- for word in words:
- if word.lower() not in lower_words_dict:
- lower_words_dict[word.lower()] = 1
- else:
- lower_words_dict[word.lower()] += 1
- for i in lower_words_dict.keys():
- if lower_words_dict[i] > 1:
- print(i, end=' ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement