Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
DreamPie 1.2.1
>>> for znak in 'ahoj':
... print(znak)
a
h
o
j
>>> for znak in enumerate('ahoj'):
... print(znak)
(0, 'a')
(1, 'h')
(2, 'o')
(3, 'j')
>>> for znak in enumerate('ahoj', start=1):
... print(znak)
(1, 'a')
(2, 'h')
(3, 'o')
(4, 'j')
>>> znak
0: (4, 'j')
>>> del znak
>>> znak
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
znak
NameError: name 'znak' is not defined
>>> list(range(10))
1: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> xs = list(range(5))
>>> xs
2: [0, 1, 2, 3, 4]
>>> xs[0]
3: 0
>>> xs[-1]
4: 4
>>> dir(xs)
5: ['__add__',
'__class__',
'__class_getitem__',
'__contains__',
'__delattr__',
'__delitem__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
'__getstate__',
'__gt__',
'__hash__',
'__iadd__',
'__imul__',
'__init__',
'__init_subclass__',
'__iter__',
'__le__',
'__len__',
'__lt__',
'__mul__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__reversed__',
'__rmul__',
'__setattr__',
'__setitem__',
'__sizeof__',
'__str__',
'__subclasshook__',
'append',
'clear',
'copy',
'count',
'extend',
'index',
'insert',
'pop',
'remove',
'reverse',
'sort']
[About 47 more lines. Double-click to unfold]
>>> xs
6: [0, 1, 2, 3, 4]
>>> xs.append('abc')
>>> xs
7: [0, 1, 2, 3, 4, 'abc']
>>> xs.pop()
8: 'abc'
>>> xs
9: [0, 1, 2, 3, 4]
>>> xs.pop()
10: 4
>>> xs
11: [0, 1, 2, 3]
>>> xs.append( ('abc', 'def') )
>>> xs
12: [0, 1, 2, 3, ('abc', 'def')]
>>> xs.append(666)
>>> xs
13: [0, 1, 2, 3, ('abc', 'def'), 666]
>>> xs.pop()
14: 666
>>> xs
15: [0, 1, 2, 3, ('abc', 'def')]
>>> xs.pop()
16: ('abc', 'def')
>>> xs
17: [0, 1, 2, 3]
>>> xs.pop(0)
18: 0
>>> xs
19: [1, 2, 3]
>>> xs.insert('abc', 0)
Traceback (most recent call last):
File "<pyshell#29>", line 1, in <module>
xs.insert('abc', 0)
TypeError: 'str' object cannot be interpreted as an integer
>>> xs.insert(0, 'abc')
>>> xs
20: ['abc', 1, 2, 3]
>>> xs.extend( ('abc', 'def') )
>>> xs
21: ['abc', 1, 2, 3, 'abc', 'def']
>>> xs.extend('ghijkl')
>>> xs
22: ['abc', 1, 2, 3, 'abc', 'def', 'g', 'h', 'i', 'j', 'k', 'l']
>>> xs.pop()
23: 'l'
>>> xs
24: ['abc', 1, 2, 3, 'abc', 'def', 'g', 'h', 'i', 'j', 'k']
>>> list()
25: []
>>> dict()
26: {}
>>> dir({})
27: ['__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]
>>> ds = { 'a': 1, 'b': [1,2,3], 'c': "ahoj", }
>>> ds
28: {'a': 1, 'b': [1, 2, 3], 'c': 'ahoj'}
>>> ds['a']
29: 1
>>> ds['c']
30: 'ahoj'
>>> xs = 1, 2, 3
>>> xs
31: (1, 2, 3)
>>> type(xs)
32: <class 'tuple'>
>>> dir(xs)
33: ['__add__',
'__class__',
'__class_getitem__',
'__contains__',
'__delattr__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
'__getnewargs__',
'__getstate__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__iter__',
'__le__',
'__len__',
'__lt__',
'__mul__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__rmul__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'count',
'index']
>>> xs.index(3)
34: 2
>>> xs = 1, print, 'Ahoj!'
>>> xs
35: (1, <built-in function print>, 'Ahoj!')
>>> xs.index(print)
36: 1
>>> xs.count(print)
37: 1
>>> xs.count('Ahoj!')
38: 1
>>> xs[-1]
39: 'Ahoj!'
>>> xs[-1] = 666
Traceback (most recent call last):
File "<pyshell#56>", line 1, in <module>
xs[-1] = 666
~~^^^^
TypeError: 'tuple' object does not support item assignment
>>> xs
40: (1, <built-in function print>, 'Ahoj!')
>>> ys = [1, print, 'Ahoj!']
>>> ys
41: [1, <built-in function print>, 'Ahoj!']
>>> ys.count(print)
42: 1
>>> ys[-1]
43: 'Ahoj!'
>>> ys[-1] = 666
>>> ys
44: [1, <built-in function print>, 666]
>>> xs = 1, [], 3
>>> xs
45: (1, [], 3)
>>> type(xs)
46: <class 'tuple'>
>>> xs[1]
47: []
>>> xs[1].append(666)
>>> xs
48: (1, [666], 3)
>>> xs = 'ahoj'
>>> xs
49: 'ahoj'
>>> type(xs)
50: <class 'str'>
>>> xs[-1]
51: 'j'
>>> xs[-1] = '!'
Traceback (most recent call last):
File "<pyshell#74>", line 1, in <module>
xs[-1] = '!'
~~^^^^
TypeError: 'str' object does not support item assignment
>>> xs
52: 'ahoj'
>>> ds
53: {'a': 1, 'b': [1, 2, 3], 'c': 'ahoj'}
>>> xs
54: 'ahoj'
>>> ys
55: [1, <built-in function print>, 666]
>>> 1 in ys
56: True
>>> print in ys
57: True
>>> 333 in ys
58: False
>>> 333 not in ys
59: True
>>> xs
60: 'ahoj'
>>> 'a' in xs
61: True
>>> 'aho' in xs
62: True
>>> 'ho' in xs
63: True
>>> 'ho' not in xs
64: False
>>> ds
65: {'a': 1, 'b': [1, 2, 3], 'c': 'ahoj'}
>>> 'a' in ds
66: True
>>> ds['a']
67: 1
>>> ds['c']
68: 'ahoj'
>>> 'ahoj' in ds
69: False
>>> for x in 'ahoj':
... print(x)
a
h
o
j
>>> for x in range(5):
... print(x)
0
1
2
3
4
>>> xs
70: 'ahoj'
>>> ys
71: [1, <built-in function print>, 666]
>>> for x in ys:
... print(x)
1
<built-in function print>
666
>>> ds
72: {'a': 1, 'b': [1, 2, 3], 'c': 'ahoj'}
>>> for x in ds:
... print(x)
a
b
c
>>> for x in ds.items():
... print(x)
('a', 1)
('b', [1, 2, 3])
('c', 'ahoj')
>>> for x in ds.values():
... print(x)
1
[1, 2, 3]
ahoj
>>> for x in ds:
... print(x)
a
b
c
>>> for x in ds.keys():
... print(x)
a
b
c
>>> 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 x in ds:
... print(x)
a
b
c
>>> for x in reversed(ds):
... print(x)
c
b
a
>>> for x in 'Abrakadabra!':
... print(x)
A
b
r
a
k
a
d
a
b
r
a
!
>>> for x in reversed('Abrakadabra!'):
... print(x)
!
a
r
b
a
d
a
k
a
r
b
A
>>> for x in sorted('Abrakadabra!'):
... print(x)
!
A
a
a
a
a
b
b
d
k
r
r
>>> for x in sorted('Abrakadábra!'):
... print(x)
!
A
a
a
a
b
b
d
k
r
r
á
>>> for x in sorted('žluťoučký kůň úpěl ďábelské ódy'):
... print(x)
b
d
e
k
k
k
l
l
l
o
p
s
u
u
y
á
é
ó
ú
ý
č
ď
ě
ň
ť
ů
ž
[About 30 more lines. Double-click to unfold]
>>> for x in sorted('žluťoučký kůň úpěl ďábelské ódy'.upper()):
... print(x)
B
D
E
K
K
K
L
L
L
O
P
S
U
U
Y
Á
É
Ó
Ú
Ý
Č
Ď
Ě
Ň
Ť
Ů
Ž
[About 30 more lines. Double-click to unfold]
>>> ord('ž')
73: 382
>>> ord('ž')
74: 382
>>> ord('Ž')
75: 381
>>> chr(381)
76: 'Ž'
>>> ds
77: {'a': 1, 'b': [1, 2, 3], 'c': 'ahoj'}
>>> ds['c']
78: 'ahoj'
>>> ds['d']
Traceback (most recent call last):
File "<pyshell#120>", line 1, in <module>
ds['d']
~~^^^^^
KeyError: 'd'
>>> if 'd' in ds:
... print(ds['d'])
>>> 'd' in ds
79: False
>>> ds.get('c')
80: 'ahoj'
>>> ds.get('d')
>>> print(ds.get('d'))
None
>>> ds
81: {'a': 1, 'b': [1, 2, 3], 'c': 'ahoj'}
>>> ds.get('d', 'Chybějící klíč!')
82: 'Chybějící klíč!'
>>> ds.get('c', 'Chybějící klíč!')
83: 'ahoj'
>>> '1234 ahoj 1234'.strip()
84: '1234 ahoj 1234'
>>> ' 1234 ahoj 1234\n'.strip()
85: '1234 ahoj 1234'
>>> '1234 ahoj 1234'.strip(123)
Traceback (most recent call last):
File "<pyshell#131>", line 1, in <module>
'1234 ahoj 1234'.strip(123)
TypeError: strip arg must be None or str
>>> '1234 ahoj 1234'.strip('123')
86: '4 ahoj 1234'
>>> '1234 ahoj 1234'.strip('321')
87: '4 ahoj 1234'
>>> '1234 ahoj 1234'.strip('3241')
88: ' ahoj '
>>> '1234 ahoj 1234'.strip('32 41')
89: 'ahoj'
>>> '1234 ahoj 1234'.lstrip('32 41')
90: 'ahoj 1234'
>>> '1234 ahoj 1234'.rstrip('32 41')
91: '1234 ahoj'
>>> xs = "1;Harry Potter and the Philosopher's Stone;2001;Chris Columbus"
>>> xs
92: "1;Harry Potter and the Philosopher's Stone;2001;Chris Columbus"
>>> ys = '1;Harry Potter and the Philosopher\'s Stone;2001;Chris Columbus'
>>> ys
93: "1;Harry Potter and the Philosopher's Stone;2001;Chris Columbus"
>>> zs = "1;Harry Potter and the \"Philosopher's Stone\";2001;Chris Columbus"
>>> zs
94: '1;Harry Potter and the "Philosopher\'s Stone";2001;Chris Columbus'
>>> xs
95: "1;Harry Potter and the Philosopher's Stone;2001;Chris Columbus"
>>> xs.split(';')
96: ['1', "Harry Potter and the Philosopher's Stone", '2001', 'Chris Columbus']
>>> xs.split()
97: ['1;Harry',
'Potter',
'and',
'the',
"Philosopher's",
'Stone;2001;Chris',
'Columbus']
>>> xs.split('and')
98: ['1;Harry Potter ', " the Philosopher's Stone;2001;Chris Columbus"]
>>> xs
99: "1;Harry Potter and the Philosopher's Stone;2001;Chris Columbus"
>>> xs.split(';')
100: ['1', "Harry Potter and the Philosopher's Stone", '2001', 'Chris Columbus']
>>> a, b, c, d = xs.split(';')
>>> a
101: '1'
>>> b
102: "Harry Potter and the Philosopher's Stone"
>>> c
103: '2001'
>>> d
104: 'Chris Columbus'
>>> _, b, _, _ = xs.split(';')
>>> b
105: "Harry Potter and the Philosopher's Stone"
>>> _
106: "Harry Potter and the Philosopher's Stone"
>>> _3
107: 0
>>> _
108: 0
>>> len('Harry Potter and the')
109: 20
>>> len('Harry Potter and the ')
110: 21
>>> "Harry Potter and the Philosopher's Stone"[:22]
111: 'Harry Potter and the P'
>>> "Harry Potter and the Philosopher's Stone"[22:]
112: "hilosopher's Stone"
>>> "Harry Potter and the Philosopher's Stone"[21:]
113: "Philosopher's Stone"
>>> sorted("Philosopher's Stone")
114: [' ',
"'",
'P',
'S',
'e',
'e',
'h',
'h',
'i',
'l',
'n',
'o',
'o',
'o',
'p',
'r',
's',
's',
't']
>>>