ABIX_Edukacja

CMI-20210429

Apr 29th, 2021
592
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Python 3.8.5 (default, Jan 27 2021, 15:41:15)
  2. [GCC 9.3.0] on linux
  3. Type "help", "copyright", "credits" or "license()" for more information.
  4. >>> slownik = { "klucz" : "wartość" }
  5. >>> slownik
  6. {'klucz': 'wartość'}
  7. >>> slownik["klucz"]
  8. 'wartość'
  9. >>> slownik["klucz_1"] = "Adam"
  10. >>> slownik
  11. {'klucz': 'wartość', 'klucz_1': 'Adam'}
  12. >>> slownik["klucz"] = "Python"
  13. >>> slownik
  14. {'klucz': 'Python', 'klucz_1': 'Adam'}
  15. >>> slownik_2 = { 1: "Adam", 45: "Jurkiewicz", 4: "Linux" }
  16. >>> slownik_2[1]
  17. 'Adam'
  18. >>> slownik_2[4]
  19. 'Linux'
  20. >>> slownik_2[45]
  21. 'Jurkiewicz'
  22. >>> slownik[len(slownik_2[1])]
  23. Traceback (most recent call last):
  24.   File "<pyshell#12>", line 1, in <module>
  25.     slownik[len(slownik_2[1])]
  26. KeyError: 4
  27. >>> slownik_2[len(slownik_2[1])]
  28. 'Linux'
  29. >>> slownik_3 = { 1 : 45.45, 2: { "A" : "Adam" } }
  30. >>> slownik_3
  31. {1: 45.45, 2: {'A': 'Adam'}}
  32. >>> slownik_3[1]
  33. 45.45
  34. >>> slownik_3[2]
  35. {'A': 'Adam'}
  36. >>> slownik_3[2]["A"]
  37. 'Adam'
  38. >>> slownik_3[1]["A"]
  39. Traceback (most recent call last):
  40.   File "<pyshell#19>", line 1, in <module>
  41.     slownik_3[1]["A"]
  42. TypeError: 'float' object is not subscriptable
  43. >>> places = {
  44.     "Anglia_1": {
  45.         "background_file": "rooms-england-bletchley-park-01.jpg",
  46.         "attachment_file": "rooms-england-bletchley-park-01.png",
  47.     },
  48.     "Anglia_2": {
  49.         "background_file": "rooms-england-bletchley-park-02.jpg",
  50.         "attachment_file": "rooms-england-bletchley-park-02.png",
  51.     },
  52.     "Anglia_3": {
  53.         "background_file": "rooms-england-bletchley-park-03.jpg",
  54.         "attachment_file": "rooms-england-bletchley-park-03.png",
  55.     },
  56.     "Francja_1": {
  57.         "background_file": "rooms-france-paris-01.jpg",
  58.         "attachment_file": "rooms-france-paris-01.png",
  59.     },
  60.     "Francja_2": {
  61.         "background_file": "rooms-france-paris-02.jpg",
  62.         "attachment_file": "rooms-france-paris-02.png",
  63.     },
  64.     "Francja_3": {
  65.         "background_file": "rooms-france-paris-03.jpg",
  66.         "attachment_file": "rooms-france-paris-03.png",
  67.     },
  68.     "Niemcy_1": {
  69.         "background_file": "rooms-german-uboot-01.jpg",
  70.         "attachment_file": "rooms-german-uboot-01.png",
  71.     },
  72.     "Niemcy_2": {
  73.         "background_file": "rooms-german-uboot-02.jpg",
  74.         "attachment_file": "rooms-german-uboot-02.png",
  75.     },
  76.     "Lwow_1": {
  77.         "background_file": "rooms-poland-lwow-sknilow-01.jpg",
  78.         "attachment_file": "rooms-poland-lwow-sknilow-01.png",
  79.     },
  80.     "Lwow_2": {
  81.         "background_file": "rooms-poland-lwow-sknilow-02.jpg",
  82.         "attachment_file": "rooms-poland-lwow-sknilow-02.png",
  83.     },
  84.     "Polska_1": {
  85.         "background_file": "rooms-poland-warsaw-cipher-bureau-01.jpg",
  86.         "attachment_file": "rooms-poland-warsaw-cipher-bureau-01.png",
  87.     },
  88.     "Polska_2": {
  89.         "background_file": "rooms-poland-warsaw-cipher-bureau-02.jpg",
  90.         "attachment_file": "rooms-poland-warsaw-cipher-bureau-02.png",
  91.     },
  92.     "Polska_3": {
  93.         "background_file": "rooms-poland-warsaw-cipher-bureau-03.jpg",
  94.         "attachment_file": "rooms-poland-warsaw-cipher-bureau-03.png",
  95.     },
  96.     "Polska_4": {
  97.         "background_file": "rooms-poland-warsaw-cipher-bureau-04.jpg",
  98.         "attachment_file": "rooms-poland-warsaw-cipher-bureau-04.png",
  99.     },
  100. }
  101. >>> places
  102. {'Anglia_1': {'background_file': 'rooms-england-bletchley-park-01.jpg', 'attachment_file': 'rooms-england-bletchley-park-01.png'}, 'Anglia_2': {'background_file': 'rooms-england-bletchley-park-02.jpg', 'attachment_file': 'rooms-england-bletchley-park-02.png'}, 'Anglia_3': {'background_file': 'rooms-england-bletchley-park-03.jpg', 'attachment_file': 'rooms-england-bletchley-park-03.png'}, 'Francja_1': {'background_file': 'rooms-france-paris-01.jpg', 'attachment_file': 'rooms-france-paris-01.png'}, 'Francja_2': {'background_file': 'rooms-france-paris-02.jpg', 'attachment_file': 'rooms-france-paris-02.png'}, 'Francja_3': {'background_file': 'rooms-france-paris-03.jpg', 'attachment_file': 'rooms-france-paris-03.png'}, 'Niemcy_1': {'background_file': 'rooms-german-uboot-01.jpg', 'attachment_file': 'rooms-german-uboot-01.png'}, 'Niemcy_2': {'background_file': 'rooms-german-uboot-02.jpg', 'attachment_file': 'rooms-german-uboot-02.png'}, 'Lwow_1': {'background_file': 'rooms-poland-lwow-sknilow-01.jpg', 'attachment_file': 'rooms-poland-lwow-sknilow-01.png'}, 'Lwow_2': {'background_file': 'rooms-poland-lwow-sknilow-02.jpg', 'attachment_file': 'rooms-poland-lwow-sknilow-02.png'}, 'Polska_1': {'background_file': 'rooms-poland-warsaw-cipher-bureau-01.jpg', 'attachment_file': 'rooms-poland-warsaw-cipher-bureau-01.png'}, 'Polska_2': {'background_file': 'rooms-poland-warsaw-cipher-bureau-02.jpg', 'attachment_file': 'rooms-poland-warsaw-cipher-bureau-02.png'}, 'Polska_3': {'background_file': 'rooms-poland-warsaw-cipher-bureau-03.jpg', 'attachment_file': 'rooms-poland-warsaw-cipher-bureau-03.png'}, 'Polska_4': {'background_file': 'rooms-poland-warsaw-cipher-bureau-04.jpg', 'attachment_file': 'rooms-poland-warsaw-cipher-bureau-04.png'}}
  103. >>> for sc in places:
  104.     print(sc)
  105.  
  106.    
  107. Anglia_1
  108. Anglia_2
  109. Anglia_3
  110. Francja_1
  111. Francja_2
  112. Francja_3
  113. Niemcy_1
  114. Niemcy_2
  115. Lwow_1
  116. Lwow_2
  117. Polska_1
  118. Polska_2
  119. Polska_3
  120. Polska_4
  121. >>> for sc in places:
  122.     print(sc)
  123.     print(plases[sc])
  124.  
  125.    
  126. Anglia_1
  127. Traceback (most recent call last):
  128.   File "<pyshell#27>", line 3, in <module>
  129.     print(plases[sc])
  130. NameError: name 'plases' is not defined
  131. >>> for sc in places:
  132.     print(sc)
  133.     print(places[sc])
  134.  
  135.    
  136. Anglia_1
  137. {'background_file': 'rooms-england-bletchley-park-01.jpg', 'attachment_file': 'rooms-england-bletchley-park-01.png'}
  138. Anglia_2
  139. {'background_file': 'rooms-england-bletchley-park-02.jpg', 'attachment_file': 'rooms-england-bletchley-park-02.png'}
  140. Anglia_3
  141. {'background_file': 'rooms-england-bletchley-park-03.jpg', 'attachment_file': 'rooms-england-bletchley-park-03.png'}
  142. Francja_1
  143. {'background_file': 'rooms-france-paris-01.jpg', 'attachment_file': 'rooms-france-paris-01.png'}
  144. Francja_2
  145. {'background_file': 'rooms-france-paris-02.jpg', 'attachment_file': 'rooms-france-paris-02.png'}
  146. Francja_3
  147. {'background_file': 'rooms-france-paris-03.jpg', 'attachment_file': 'rooms-france-paris-03.png'}
  148. Niemcy_1
  149. {'background_file': 'rooms-german-uboot-01.jpg', 'attachment_file': 'rooms-german-uboot-01.png'}
  150. Niemcy_2
  151. {'background_file': 'rooms-german-uboot-02.jpg', 'attachment_file': 'rooms-german-uboot-02.png'}
  152. Lwow_1
  153. {'background_file': 'rooms-poland-lwow-sknilow-01.jpg', 'attachment_file': 'rooms-poland-lwow-sknilow-01.png'}
  154. Lwow_2
  155. {'background_file': 'rooms-poland-lwow-sknilow-02.jpg', 'attachment_file': 'rooms-poland-lwow-sknilow-02.png'}
  156. Polska_1
  157. {'background_file': 'rooms-poland-warsaw-cipher-bureau-01.jpg', 'attachment_file': 'rooms-poland-warsaw-cipher-bureau-01.png'}
  158. Polska_2
  159. {'background_file': 'rooms-poland-warsaw-cipher-bureau-02.jpg', 'attachment_file': 'rooms-poland-warsaw-cipher-bureau-02.png'}
  160. Polska_3
  161. {'background_file': 'rooms-poland-warsaw-cipher-bureau-03.jpg', 'attachment_file': 'rooms-poland-warsaw-cipher-bureau-03.png'}
  162. Polska_4
  163. {'background_file': 'rooms-poland-warsaw-cipher-bureau-04.jpg', 'attachment_file': 'rooms-poland-warsaw-cipher-bureau-04.png'}
  164. >>> dir(places)
  165. ['__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'items', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']
  166. >>> places.keys()
  167. dict_keys(['Anglia_1', 'Anglia_2', 'Anglia_3', 'Francja_1', 'Francja_2', 'Francja_3', 'Niemcy_1', 'Niemcy_2', 'Lwow_1', 'Lwow_2', 'Polska_1', 'Polska_2', 'Polska_3', 'Polska_4'])
  168. >>> from random import randint, choice
  169. >>> help(choice())
  170. Traceback (most recent call last):
  171.   File "<pyshell#33>", line 1, in <module>
  172.     help(choice())
  173. TypeError: choice() missing 1 required positional argument: 'seq'
  174. >>> help(choice)
  175. Help on method choice in module random:
  176.  
  177. choice(seq) method of random.Random instance
  178.     Choose a random element from a non-empty sequence.
  179.  
  180. >>> choice(places.keys())
  181. Traceback (most recent call last):
  182.   File "<pyshell#35>", line 1, in <module>
  183.     choice(places.keys())
  184.   File "/usr/lib/python3.8/random.py", line 291, in choice
  185.     return seq[i]
  186. TypeError: 'dict_keys' object is not subscriptable
  187. >>> choice(dict(places.keys()))
  188. Traceback (most recent call last):
  189.   File "<pyshell#36>", line 1, in <module>
  190.     choice(dict(places.keys()))
  191. ValueError: dictionary update sequence element #0 has length 8; 2 is required
  192. >>> choice(list(places.keys()))
  193. 'Anglia_3'
  194. >>> choice(list(places.keys()))
  195. 'Francja_1'
  196. >>> choice(list(places.keys()))
  197. 'Lwow_2'
  198. >>> choice(list(places.keys()))
  199. 'Niemcy_1'
  200. >>> choice(list(places.keys()))
  201. 'Polska_2'
  202. >>> choice(list(places.keys()))
  203. 'Anglia_1'
  204. >>> choice(list(places.keys()))
  205. 'Polska_3'
  206. >>> choice(list(places.keys()))
  207. 'Polska_4'
  208. >>> choice(list(places.keys()))
  209. 'Anglia_1'
  210. >>> choice(list(places.keys()))
  211. 'Francja_3'
  212. >>> choice(list(places.keys()))
  213. 'Lwow_1'
  214. >>> choice(list(places.keys()))
  215. 'Polska_2'
  216. >>> choice(list(places.keys()))
  217. 'Polska_2'
  218. >>> choice(list(places.keys()))
  219. 'Francja_3'
  220. >>> place = "Polska_2"
  221. >>> places[place]["background_file"]
  222. 'rooms-poland-warsaw-cipher-bureau-02.jpg'
  223. >>> import json
  224. >>> dir(json)
  225. ['JSONDecodeError', 'JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', '_default_decoder', '_default_encoder', 'codecs', 'decoder', 'detect_encoding', 'dump', 'dumps', 'encoder', 'load', 'loads', 'scanner']
  226. >>> places
  227. {'Anglia_1': {'background_file': 'rooms-england-bletchley-park-01.jpg', 'attachment_file': 'rooms-england-bletchley-park-01.png'}, 'Anglia_2': {'background_file': 'rooms-england-bletchley-park-02.jpg', 'attachment_file': 'rooms-england-bletchley-park-02.png'}, 'Anglia_3': {'background_file': 'rooms-england-bletchley-park-03.jpg', 'attachment_file': 'rooms-england-bletchley-park-03.png'}, 'Francja_1': {'background_file': 'rooms-france-paris-01.jpg', 'attachment_file': 'rooms-france-paris-01.png'}, 'Francja_2': {'background_file': 'rooms-france-paris-02.jpg', 'attachment_file': 'rooms-france-paris-02.png'}, 'Francja_3': {'background_file': 'rooms-france-paris-03.jpg', 'attachment_file': 'rooms-france-paris-03.png'}, 'Niemcy_1': {'background_file': 'rooms-german-uboot-01.jpg', 'attachment_file': 'rooms-german-uboot-01.png'}, 'Niemcy_2': {'background_file': 'rooms-german-uboot-02.jpg', 'attachment_file': 'rooms-german-uboot-02.png'}, 'Lwow_1': {'background_file': 'rooms-poland-lwow-sknilow-01.jpg', 'attachment_file': 'rooms-poland-lwow-sknilow-01.png'}, 'Lwow_2': {'background_file': 'rooms-poland-lwow-sknilow-02.jpg', 'attachment_file': 'rooms-poland-lwow-sknilow-02.png'}, 'Polska_1': {'background_file': 'rooms-poland-warsaw-cipher-bureau-01.jpg', 'attachment_file': 'rooms-poland-warsaw-cipher-bureau-01.png'}, 'Polska_2': {'background_file': 'rooms-poland-warsaw-cipher-bureau-02.jpg', 'attachment_file': 'rooms-poland-warsaw-cipher-bureau-02.png'}, 'Polska_3': {'background_file': 'rooms-poland-warsaw-cipher-bureau-03.jpg', 'attachment_file': 'rooms-poland-warsaw-cipher-bureau-03.png'}, 'Polska_4': {'background_file': 'rooms-poland-warsaw-cipher-bureau-04.jpg', 'attachment_file': 'rooms-poland-warsaw-cipher-bureau-04.png'}}
  228. >>> json.dumps(places)
  229. '{"Anglia_1": {"background_file": "rooms-england-bletchley-park-01.jpg", "attachment_file": "rooms-england-bletchley-park-01.png"}, "Anglia_2": {"background_file": "rooms-england-bletchley-park-02.jpg", "attachment_file": "rooms-england-bletchley-park-02.png"}, "Anglia_3": {"background_file": "rooms-england-bletchley-park-03.jpg", "attachment_file": "rooms-england-bletchley-park-03.png"}, "Francja_1": {"background_file": "rooms-france-paris-01.jpg", "attachment_file": "rooms-france-paris-01.png"}, "Francja_2": {"background_file": "rooms-france-paris-02.jpg", "attachment_file": "rooms-france-paris-02.png"}, "Francja_3": {"background_file": "rooms-france-paris-03.jpg", "attachment_file": "rooms-france-paris-03.png"}, "Niemcy_1": {"background_file": "rooms-german-uboot-01.jpg", "attachment_file": "rooms-german-uboot-01.png"}, "Niemcy_2": {"background_file": "rooms-german-uboot-02.jpg", "attachment_file": "rooms-german-uboot-02.png"}, "Lwow_1": {"background_file": "rooms-poland-lwow-sknilow-01.jpg", "attachment_file": "rooms-poland-lwow-sknilow-01.png"}, "Lwow_2": {"background_file": "rooms-poland-lwow-sknilow-02.jpg", "attachment_file": "rooms-poland-lwow-sknilow-02.png"}, "Polska_1": {"background_file": "rooms-poland-warsaw-cipher-bureau-01.jpg", "attachment_file": "rooms-poland-warsaw-cipher-bureau-01.png"}, "Polska_2": {"background_file": "rooms-poland-warsaw-cipher-bureau-02.jpg", "attachment_file": "rooms-poland-warsaw-cipher-bureau-02.png"}, "Polska_3": {"background_file": "rooms-poland-warsaw-cipher-bureau-03.jpg", "attachment_file": "rooms-poland-warsaw-cipher-bureau-03.png"}, "Polska_4": {"background_file": "rooms-poland-warsaw-cipher-bureau-04.jpg", "attachment_file": "rooms-poland-warsaw-cipher-bureau-04.png"}}'
  230. >>> json.dumps(plases, indent=3)
  231. Traceback (most recent call last):
  232.   File "<pyshell#57>", line 1, in <module>
  233.     json.dumps(plases, indent=3)
  234. NameError: name 'plases' is not defined
  235. >>> json.dumps(places, indent=3)
  236. '{\n   "Anglia_1": {\n      "background_file": "rooms-england-bletchley-park-01.jpg",\n      "attachment_file": "rooms-england-bletchley-park-01.png"\n   },\n   "Anglia_2": {\n      "background_file": "rooms-england-bletchley-park-02.jpg",\n      "attachment_file": "rooms-england-bletchley-park-02.png"\n   },\n   "Anglia_3": {\n      "background_file": "rooms-england-bletchley-park-03.jpg",\n      "attachment_file": "rooms-england-bletchley-park-03.png"\n   },\n   "Francja_1": {\n      "background_file": "rooms-france-paris-01.jpg",\n      "attachment_file": "rooms-france-paris-01.png"\n   },\n   "Francja_2": {\n      "background_file": "rooms-france-paris-02.jpg",\n      "attachment_file": "rooms-france-paris-02.png"\n   },\n   "Francja_3": {\n      "background_file": "rooms-france-paris-03.jpg",\n      "attachment_file": "rooms-france-paris-03.png"\n   },\n   "Niemcy_1": {\n      "background_file": "rooms-german-uboot-01.jpg",\n      "attachment_file": "rooms-german-uboot-01.png"\n   },\n   "Niemcy_2": {\n      "background_file": "rooms-german-uboot-02.jpg",\n      "attachment_file": "rooms-german-uboot-02.png"\n   },\n   "Lwow_1": {\n      "background_file": "rooms-poland-lwow-sknilow-01.jpg",\n      "attachment_file": "rooms-poland-lwow-sknilow-01.png"\n   },\n   "Lwow_2": {\n      "background_file": "rooms-poland-lwow-sknilow-02.jpg",\n      "attachment_file": "rooms-poland-lwow-sknilow-02.png"\n   },\n   "Polska_1": {\n      "background_file": "rooms-poland-warsaw-cipher-bureau-01.jpg",\n      "attachment_file": "rooms-poland-warsaw-cipher-bureau-01.png"\n   },\n   "Polska_2": {\n      "background_file": "rooms-poland-warsaw-cipher-bureau-02.jpg",\n      "attachment_file": "rooms-poland-warsaw-cipher-bureau-02.png"\n   },\n   "Polska_3": {\n      "background_file": "rooms-poland-warsaw-cipher-bureau-03.jpg",\n      "attachment_file": "rooms-poland-warsaw-cipher-bureau-03.png"\n   },\n   "Polska_4": {\n      "background_file": "rooms-poland-warsaw-cipher-bureau-04.jpg",\n      "attachment_file": "rooms-poland-warsaw-cipher-bureau-04.png"\n   }\n}'
  237. >>> print(json.dumps(places, indent=3))
  238. {
  239.    "Anglia_1": {
  240.       "background_file": "rooms-england-bletchley-park-01.jpg",
  241.       "attachment_file": "rooms-england-bletchley-park-01.png"
  242.    },
  243.    "Anglia_2": {
  244.       "background_file": "rooms-england-bletchley-park-02.jpg",
  245.       "attachment_file": "rooms-england-bletchley-park-02.png"
  246.    },
  247.    "Anglia_3": {
  248.       "background_file": "rooms-england-bletchley-park-03.jpg",
  249.       "attachment_file": "rooms-england-bletchley-park-03.png"
  250.    },
  251.    "Francja_1": {
  252.       "background_file": "rooms-france-paris-01.jpg",
  253.       "attachment_file": "rooms-france-paris-01.png"
  254.    },
  255.    "Francja_2": {
  256.       "background_file": "rooms-france-paris-02.jpg",
  257.       "attachment_file": "rooms-france-paris-02.png"
  258.    },
  259.    "Francja_3": {
  260.       "background_file": "rooms-france-paris-03.jpg",
  261.       "attachment_file": "rooms-france-paris-03.png"
  262.    },
  263.    "Niemcy_1": {
  264.       "background_file": "rooms-german-uboot-01.jpg",
  265.       "attachment_file": "rooms-german-uboot-01.png"
  266.    },
  267.    "Niemcy_2": {
  268.       "background_file": "rooms-german-uboot-02.jpg",
  269.       "attachment_file": "rooms-german-uboot-02.png"
  270.    },
  271.    "Lwow_1": {
  272.       "background_file": "rooms-poland-lwow-sknilow-01.jpg",
  273.       "attachment_file": "rooms-poland-lwow-sknilow-01.png"
  274.    },
  275.    "Lwow_2": {
  276.       "background_file": "rooms-poland-lwow-sknilow-02.jpg",
  277.       "attachment_file": "rooms-poland-lwow-sknilow-02.png"
  278.    },
  279.    "Polska_1": {
  280.       "background_file": "rooms-poland-warsaw-cipher-bureau-01.jpg",
  281.       "attachment_file": "rooms-poland-warsaw-cipher-bureau-01.png"
  282.    },
  283.    "Polska_2": {
  284.       "background_file": "rooms-poland-warsaw-cipher-bureau-02.jpg",
  285.       "attachment_file": "rooms-poland-warsaw-cipher-bureau-02.png"
  286.    },
  287.    "Polska_3": {
  288.       "background_file": "rooms-poland-warsaw-cipher-bureau-03.jpg",
  289.       "attachment_file": "rooms-poland-warsaw-cipher-bureau-03.png"
  290.    },
  291.    "Polska_4": {
  292.       "background_file": "rooms-poland-warsaw-cipher-bureau-04.jpg",
  293.       "attachment_file": "rooms-poland-warsaw-cipher-bureau-04.png"
  294.    }
  295. }
  296. >>>
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×