Python 3.13.0 (tags/v3.13.0:60403a5, Oct 7 2024, 09:38:07) [MSC v.1941 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
DreamPie 1.2.1
>>> xs = {
...
... 'abc': print,
... (1, 'a'): 'Ahoj!',
... 333: [1, 2, 3],
... }
>>> xs
0: {333: [1, 2, 3], 'abc': <built-in function print>, (1, 'a'): 'Ahoj!'}
>>> type(xs)
1: <class 'dict'>
>>> dir(xs)
2: ['__class__',
'__class_getitem__',
'__contains__',
'__delattr__',
'__delitem__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
'__getstate__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__ior__',
'__iter__',
'__le__',
'__len__',
'__lt__',
'__ne__',
'__new__',
'__or__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__reversed__',
'__ror__',
'__setattr__',
'__setitem__',
'__sizeof__',
'__str__',
'__subclasshook__',
'clear',
'copy',
'fromkeys',
'get',
'items',
'keys',
'pop',
'popitem',
'setdefault',
'update',
'values']
[About 45 more lines. Double-click to unfold]
>>> xs['abc']
3: <built-in function print>
>>> xs[333]
4: [1, 2, 3]
>>> xs[(1, 'a')]
5: 'Ahoj!'
>>> xs[1, 'a']
6: 'Ahoj!'
>>> xs.keys()
7: dict_keys(['abc', (1, 'a'), 333])
>>> xs.values()
8: dict_values([<built-in function print>, 'Ahoj!', [1, 2, 3]])
>>> xs.items()
9: dict_items([('abc', <built-in function print>), ((1, 'a'), 'Ahoj!'), (333, [1, 2, 3])])
>>> for x in xs:
... print(x)
abc
(1, 'a')
333
>>> for x in xs.keys():
... print(x)
abc
(1, 'a')
333
>>> for x in xs.values():
... print(x)
<built-in function print>
Ahoj!
[1, 2, 3]
>>> for x in xs.items():
... print(x)
('abc', <built-in function print>)
((1, 'a'), 'Ahoj!')
(333, [1, 2, 3])
>>> for x in xs:
... print(x, xs[x])
abc <built-in function print>
(1, 'a') Ahoj!
333 [1, 2, 3]
>>> for x in xs:
... print(x, '-->', xs[x])
abc --> <built-in function print>
(1, 'a') --> Ahoj!
333 --> [1, 2, 3]
>>> for key,value in xs.items():
... print(key, '-->', value)
abc --> <built-in function print>
(1, 'a') --> Ahoj!
333 --> [1, 2, 3]
>>> for k,v in xs.items():
... print(k, '-->', v)
abc --> <built-in function print>
(1, 'a') --> Ahoj!
333 --> [1, 2, 3]
>>> xs
10: {333: [1, 2, 3], 'abc': <built-in function print>, (1, 'a'): 'Ahoj!'}
>>> xs['abc'] = abs
>>> xs
11: {333: [1, 2, 3], 'abc': <built-in function abs>, (1, 'a'): 'Ahoj!'}
>>> xs[666] = 'Baf!'
>>> xs
12: {333: [1, 2, 3], 666: 'Baf!', 'abc': <built-in function abs>, (1, 'a'): 'Ahoj!'}
>>> xs
13: {333: [1, 2, 3], 666: 'Baf!', 'abc': <built-in function abs>, (1, 'a'): 'Ahoj!'}
>>> len(xs)
14: 4
>>> 333 in xs
15: True
>>> 444 in xs
16: False
>>> (1, 'a') in xs
17: True
>>> 1, 'a' in xs
18: (1, False)
>>> xs[333]
19: [1, 2, 3]
>>> xs[444]
Traceback (most recent call last):
File "<pyshell#31>", line 1, in <module>
xs[444]
~~^^^^^
KeyError: 444
>>> if 444 in xs:
... print(xs[444])
>>> if 333 in xs:
... print(xs[333])
[1, 2, 3]
>>> if 333 in xs:
... print(xs[444])
Traceback (most recent call last):
File "<pyshell#34>", line 2, in <module>
print(xs[444])
~~^^^^^
KeyError: 444
>>> xs.get(333)
20: [1, 2, 3]
>>> xs.get(444)
>>> print(xs.get(444))
None
>>> xs.get(333, 'není')
21: [1, 2, 3]
>>> xs.get(444, 'není')
22: 'není'
>>> ys = [('c', 'ahoj'), (666, 'lokus')]
>>> type(ys)
23: <class 'list'>
>>> type(ys[0])
24: <class 'tuple'>
>>> type(ys[1])
25: <class 'tuple'>
>>> dict(ys)
26: {666: 'lokus', 'c': 'ahoj'}
>>> xs
27: {333: [1, 2, 3], 666: 'Baf!', 'abc': <built-in function abs>, (1, 'a'): 'Ahoj!'}
>>> del xs[666]
>>> xs
28: {333: [1, 2, 3], 'abc': <built-in function abs>, (1, 'a'): 'Ahoj!'}
>>> xs.pop(333)
29: [1, 2, 3]
>>> xs
30: {'abc': <built-in function abs>, (1, 'a'): 'Ahoj!'}
>>> xs.pop(444)
Traceback (most recent call last):
File "<pyshell#50>", line 1, in <module>
xs.pop(444)
~~~~~~^^^^^
KeyError: 444
>>> xs.pop(444, 'abc')
31: 'abc'
>>> xs
32: {'abc': <built-in function abs>, (1, 'a'): 'Ahoj!'}
>>> xs.popitem()
33: ((1, 'a'), 'Ahoj!')
>>> xs
34: {'abc': <built-in function abs>}
>>> xs.popitem()
35: ('abc', <built-in function abs>)
>>> xs
36: {}
>>> {i:j for i in range(1, 4) for j in 'abc'}
37: {1: 'c', 2: 'c', 3: 'c'}
>>> {i:j for i in range(1, 4) for j in 'ab'}
38: {1: 'b', 2: 'b', 3: 'b'}
>>> [(i,j) for i in range(1, 4) for j in 'abc']
39: [(1, 'a'),
(1, 'b'),
(1, 'c'),
(2, 'a'),
(2, 'b'),
(2, 'c'),
(3, 'a'),
(3, 'b'),
(3, 'c')]
>>> [(i,j) for i in range(1, 11) if i % 2 == 0]
Traceback (most recent call last):
File "<pyshell#60>", line 1, in <module>
[(i,j) for i in range(1, 11) if i % 2 == 0]
^
NameError: name 'j' is not defined
>>> {i:j for i in range(1, 11) if i % 2 == 0}
Traceback (most recent call last):
File "<pyshell#61>", line 1, in <module>
{i:j for i in range(1, 11) if i % 2 == 0}
^
NameError: name 'j' is not defined
>>> {i:'' for i in range(1, 11) if i % 2 == 0}
40: {2: '', 4: '', 6: '', 8: '', 10: ''}
>>> {i:'' for i in range(1, 11) if i % 2 == 1}
41: {1: '', 3: '', 5: '', 7: '', 9: ''}
>>> set()
42: set()
>>> {}
43: {}
>>> type({})
44: <class 'dict'>
>>> type(set())
45: <class 'set'>
>>>
>>> (3, 2, 7, 1, 6)
46: (3, 2, 7, 1, 6)
>>> max( (3, 2, 7, 1, 6) )
47: 7
>>> max( ('t', 'a', 'z', 'p') )
48: 'z'
>>> max( ('t', 'a', 'A', 'z', 'p') )
49: 'z'
>>> for i in range(32, 100):
... print(chr(i), end=' ')
! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c
>>> for i in range(32, 127):
... print(chr(i), end=' ')
! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~
>>>