Advertisement
boyan1324

23401

Jun 8th, 2024
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.30 KB | None | 0 0
  1. # 1
  2. students = input().split()
  3. students_dict = {}
  4. for i in range(0, len(students), 2):
  5.     student = students[i]
  6.     number = int(students[i+1])
  7.     students_dict[student] = number
  8. print(students_dict)
  9.  
  10. # 2
  11. products = input().split()
  12. order = input().split()
  13. products_storage = {}
  14. for i in range(0, len(products), 2):
  15.     product = products[i]
  16.     quantity = int(products[i + 1])
  17.     if product not in products_storage:
  18.         products_storage[product] = quantity
  19.     else:
  20.         products_storage[product] += quantity
  21. for item in range(0, len(order)):
  22.     ordered_item = order[item]
  23.     if ordered_item in products_storage:
  24.         print(f'We have {products_storage[ordered_item]} of {ordered_item} left')
  25.     else:
  26.         print(f'Sorry, we dont have {ordered_item}')
  27.  
  28. # 3
  29. products_stock = {}
  30. while True:
  31.     command = input()
  32.     if command == 'START':
  33.         break
  34.     else:
  35.         product, quantity = command.split(': ')
  36.         quantity = int(quantity)
  37.         if product not in products_stock:
  38.             products_stock[product] = quantity
  39.         else:
  40.             products_stock[product] += quantity
  41. total_products = len(products_stock)
  42. total_quantity = sum(products_stock.values())
  43. print('Products in stock: ')
  44. for key in products_stock:
  45.     print(f'- {key}: {products_stock[key]}')
  46. print(f'Total Products: {total_products}')
  47. print(f'Total Quantity: {total_quantity}')
  48.  
  49. # 4
  50. student_dict = {'I-ви курс': [], 'II-ри курс': [], 'III-ти курс': [], 'IV-ти курс': [], 'V-ти курс': []}
  51. while True:
  52.     command = input()
  53.     if command in student_dict.keys():
  54.         final_command = command
  55.         break
  56.     else:
  57.         name, number, course = command.split(':')
  58.         student_dict[course].append((name, number))
  59. for student in student_dict[final_command]:
  60.     print(f"{student[0]} - {student[1]}")
  61.  
  62.  
  63. # 5
  64. ascii_dict = {}
  65. ascii_input = input().split(', ')
  66. for item in ascii_input:
  67.     ascii_dict[item] = ord(item)
  68. print(ascii_dict)
  69.  
  70. # 6
  71. words = input().split()
  72. lower_words_dict = {}
  73. for word in words:
  74.     if word.lower() not in lower_words_dict:
  75.         lower_words_dict[word.lower()] = 1
  76.     else:
  77.         lower_words_dict[word.lower()] += 1
  78. for i in lower_words_dict.keys():
  79.     if lower_words_dict[i] > 1:
  80.         print(i, end=' ')
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement