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
>>> 0.2 + 0.2
0: 0.4
>>> 0.2 + 0.2 + 0.2
1: 0.6000000000000001
>>> 0.2 + 0.2 + 0.2 + 0.2
2: 0.8
>>> 0.2 + 0.2 + 0.2 + 0.2 + 0.2
3: 1.0
>>> 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2
4: 1.2
>>> 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2
5: 1.4
>>> 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2
6: 1.5999999999999999
>>> 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2
7: 1.7999999999999998
>>> 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2
8: 1.9999999999999998
>>> 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2
9: 2.1999999999999997
>>> ds = {
... 'a': 1,
... 'b': [1,2,3],
... 'c': "ahoj",
... }
>>> type(ds)
10: <class 'dict'>
>>> ds[0]
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
ds[0]
~~^^^
KeyError: 0
>>> ds['a']
11: 1
>>> ds['b']
12: [1, 2, 3]
>>> for key in ds:
... print(key)
a
b
c
>>> for key in reversed(ds):
... print(key)
c
b
a
>>> hash(1)
13: 1
>>> hash(1.0)
14: 1
>>> hash('1')
15: -1848396693362088903
>>> hash(('1', ))
16: 6521239249182570972
>>> hash(('1', 'print'))
17: -2918613596748090303
>>> hash(('1', print))
18: -1074848258947391477
>>> hash(('1', []))
Traceback (most recent call last):
File "<pyshell#23>", line 1, in <module>
hash(('1', []))
~~~~^^^^^^^^^^^
TypeError: unhashable type: 'list'
>>> ds
19: {'a': 1, 'b': [1, 2, 3], 'c': 'ahoj'}
>>> for key in ds:
... print(key, ds[key])
a 1
b [1, 2, 3]
c ahoj
>>> for key in ds.keys():
... print(key, ds[key])
a 1
b [1, 2, 3]
c ahoj
>>> for val in ds.values():
... print(val)
1
[1, 2, 3]
ahoj
>>> for key,val in ds.items():
... print(key, val)
a 1
b [1, 2, 3]
c ahoj
>>> for x in ds.items():
... print(x)
('a', 1)
('b', [1, 2, 3])
('c', 'ahoj')
>>> for k,v in ds.items():
... print(k, v)
a 1
b [1, 2, 3]
c ahoj
>>> for x in ds.items():
... k, v = x
... print(k, v)
a 1
b [1, 2, 3]
c ahoj
>>> for k,v in ds.items():
... print(k, v)
a 1
b [1, 2, 3]
c ahoj
>>> for x in enumerate(ds.items()):
... print(x)
(0, ('a', 1))
(1, ('b', [1, 2, 3]))
(2, ('c', 'ahoj'))
>>> for x in enumerate(ds.items(), start=10):
... print(x)
(10, ('a', 1))
(11, ('b', [1, 2, 3]))
(12, ('c', 'ahoj'))
>>> for i,x in enumerate(ds.items(), start=10):
... print(i, x)
10 ('a', 1)
11 ('b', [1, 2, 3])
12 ('c', 'ahoj')
>>> for i,(k,v) in enumerate(ds.items(), start=10):
... print(i, k, v)
10 a 1
11 b [1, 2, 3]
12 c ahoj
>>> {}.fromkeys('abc')
20: {'a': None, 'b': None, 'c': None}
>>> {}.fromkeys('abc', 666)
21: {'a': 666, 'b': 666, 'c': 666}
>>> {}.fromkeys('abc', [])
22: {'a': [], 'b': [], 'c': []}
>>> ds = {}.fromkeys('abc', [])
>>> ds
23: {'a': [], 'b': [], 'c': []}
>>> ds['a']
24: []
>>> ds['a'].append(333)
>>> ds['a']
25: [333]
>>> ds
26: {'a': [333], 'b': [333], 'c': [333]}
>>> ds = {}.fromkeys('abc', list())
>>> ds
27: {'a': [], 'b': [], 'c': []}
>>> ds['a']
28: []
>>> ds['a'].append(333)
>>> ds['a']
29: [333]
>>> ds
30: {'a': [333], 'b': [333], 'c': [333]}
>>> ds = {x:[] for x in 'abc'}
>>> ds
31: {'a': [], 'b': [], 'c': []}
>>> ds['a']
32: []
>>> ds['a'].append(333)
>>> ds['a']
33: [333]
>>> ds
34: {'a': [333], 'b': [], 'c': []}
>>> ds = {
... x:[]
... for x in 'abc'
... }
>>> ds
35: {'a': [], 'b': [], 'c': []}
>>> ds = {
... 'a': 1,
... 'b': [1,2,3],
... 'c': "ahoj",
... }
>>> ds
36: {'a': 1, 'b': [1, 2, 3], 'c': 'ahoj'}
>>> ds['a']
37: 1
>>> ds['d']
Traceback (most recent call last):
File "<pyshell#63>", line 1, in <module>
ds['d']
~~^^^^^
KeyError: 'd'
>>> ds.get('a')
38: 1
>>> ds.get('d')
>>> print(ds.get('d'))
None
>>> ds.get('d', 333)
39: 333
>>> ds
40: {'a': 1, 'b': [1, 2, 3], 'c': 'ahoj'}
>>> ds['a']
41: 1
>>> ds['a'] = 333
>>> ds
42: {'a': 333, 'b': [1, 2, 3], 'c': 'ahoj'}
>>> ds['d']
Traceback (most recent call last):
File "<pyshell#72>", line 1, in <module>
ds['d']
~~^^^^^
KeyError: 'd'
>>> ds['d'] = 666
>>> ds
43: {'a': 333, 'b': [1, 2, 3], 'c': 'ahoj', 'd': 666}
>>> xs = { 1, 2, 'ahoj', 3, 'b', }
>>> type(xs)
44: <class 'set'>
>>> len(xs)
45: 5
>>> len(ds)
46: 4
>>> dir(xs)
47: ['__and__',
'__class__',
'__class_getitem__',
'__contains__',
'__delattr__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getstate__',
'__gt__',
'__hash__',
'__iand__',
'__init__',
'__init_subclass__',
'__ior__',
'__isub__',
'__iter__',
'__ixor__',
'__le__',
'__len__',
'__lt__',
'__ne__',
'__new__',
'__or__',
'__rand__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__ror__',
'__rsub__',
'__rxor__',
'__setattr__',
'__sizeof__',
'__str__',
'__sub__',
'__subclasshook__',
'__xor__',
'add',
'clear',
'copy',
'difference',
'difference_update',
'discard',
'intersection',
'intersection_update',
'isdisjoint',
'issubset',
'issuperset',
'pop',
'remove',
'symmetric_difference',
'symmetric_difference_update',
'union',
'update']
>>> xs
48: {'b', 1, 2, 3, 'ahoj'}
>>> for x in xs:
... print(x)
b
1
2
3
ahoj
>>> for x in enumerate(xs):
... print(x)
(0, 'b')
(1, 1)
(2, 2)
(3, 3)
(4, 'ahoj')
>>> len(xs)
49: 5
>>>
>>> 'ahoj' in xs
50: True
>>> 'ahoj' not in xs
51: False
>>>