Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
DreamPie 1.2.1
>>> for znak in 'řetězec':
... print(znak)
ř
e
t
ě
z
e
c
>>> for znak in 'řetězec':
... print(znak, end='')
řetězec
>>> for znak in enum('řetězec'):
... print(znak)
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
for znak in enum('řetězec'):
NameError: name 'enum' is not defined
>>> for znak in enumerate('řetězec'):
... print(znak)
(0, 'ř')
(1, 'e')
(2, 't')
(3, 'ě')
(4, 'z')
(5, 'e')
(6, 'c')
>>> 'řetězec'[0]
0: 'ř'
>>> 'řetězec'[-2]
1: 'e'
>>> 'řetězec'[-2:]
2: 'ec'
>>> for znak in enumerate('řetězec', start=10):
... print(znak)
(10, 'ř')
(11, 'e')
(12, 't')
(13, 'ě')
(14, 'z')
(15, 'e')
(16, 'c')
>>> for i,znak in enumerate('řetězec', start=10):
... print(znak)
ř
e
t
ě
z
e
c
>>> for i,znak in enumerate('řetězec', start=10):
... print(i)
10
11
12
13
14
15
16
>>> for i,znak in enumerate('řetězec', start=10):
... print(i, znak)
10 ř
11 e
12 t
13 ě
14 z
15 e
16 c
>>> for i in range(10):
... print(i)
0
1
2
3
4
5
6
7
8
9
>>> range(10)
3: range(0, 10)
>>> list(range(10))
4: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> len('řetězec')
5: 7
>>> for i in range(len('řetězec')):
... print('řetězec'[i])
ř
e
t
ě
z
e
c
>>> a, b = 1, 2
>>> a
6: 1
>>> b
7: 2
>>> a, b = 1, 2, 3
Traceback (most recent call last):
File "<pyshell#19>", line 1, in <module>
a, b = 1, 2, 3
ValueError: too many values to unpack (expected 2)
>>> a, b, c = 1, 2
Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>
a, b, c = 1, 2
ValueError: not enough values to unpack (expected 3, got 2)
>>> *a, b = 1, 2, 3
>>> a
8: [1, 2]
>>> b
9: 3
>>> a, *b = 1, 2, 3
>>> a
10: 1
>>> b
11: [2, 3]
>>> a, *b = 1
Traceback (most recent call last):
File "<pyshell#27>", line 1, in <module>
a, *b = 1
TypeError: cannot unpack non-iterable int object
>>> a, *b = 1,
>>> a
12: 1
>>> b
13: []
>>> a, *b, c = 1, 2, 3, 4, 5, 6, 7
>>> a
14: 1
>>> b
15: [2, 3, 4, 5, 6]
>>> c
16: 7
>>> a, *_, c = 1, 2, 3, 4, 5, 6, 7
>>> _
17: [2, 3, 4, 5, 6]
>>> a
18: 1
>>> _
19: 1
>>> '''*a, b, *c = 1, 2, 3, 4, 5, 6, 7'''
20: '*a, b, *c = 1, 2, 3, 4, 5, 6, 7'
>>> a, b = 1, 2
>>> a
21: 1
>>> b
22: 2
>>> a, b = b, a
>>> a
23: 2
>>> b
24: 1
>>> a, b, c = 'xyz'
>>> a
25: 'x'
>>> b
26: 'y'
>>> c
27: 'z'
>>> def fn():
... return 666, 'ahoj'
>>> fn()
28: (666, 'ahoj')
>>> x = fn()
>>> x
29: (666, 'ahoj')
>>> x, y = fn()
>>> x
30: 666
>>> y
31: 'ahoj'
>>> for i in range(10):
... print(i, end=' ')
0 1 2 3 4 5 6 7 8 9
>>> range(10)
32: range(0, 10)
>>> for i in range(3, 10):
... print(i, end=' ')
3 4 5 6 7 8 9
>>> for i in range(3, 10, 3):
... print(i, end=' ')
3 6 9
>>> xs = {
... 0: 1,
... 1: 1,
... 2: 2,
... 3: 3,
... 4: 5,
... }
>>> xs = {
... 0: 1,
... 1: print,
... 2: 2,
... 3: "Ahoj!",
... 4: [1, 2, '3'],
... }
>>> hash(3)
33: 3
>>> hash('abc')
34: -804707632711823930
>>> hash( ('abc', 3, 222) )
35: 3238121243830809328
>>> xs
36: {0: 1, 1: <built-in function print>, 2: 2, 3: 'Ahoj!', 4: [1, 2, '3']}
>>> xs[3]
37: 'Ahoj!'
>>> dir(xs)
38: ['__class__',
'__class_getitem__',
'__contains__',
'__delattr__',
'__delitem__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
'__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 44 more lines. Double-click to unfold]
>>> for i in xs:
... print(i)
0
1
2
3
4
>>> for i in xs.keys():
... print(i)
0
1
2
3
4
>>> for i in xs.values():
... print(i)
1
<built-in function print>
2
Ahoj!
[1, 2, '3']
>>> for i in xs.items():
... print(i)
(0, 1)
(1, <built-in function print>)
(2, 2)
(3, 'Ahoj!')
(4, [1, 2, '3'])
>>> for key,value in xs.items():
... print(key, value)
0 1
1 <built-in function print>
2 2
3 Ahoj!
4 [1, 2, '3']
>>> for k,v in xs.items():
... print(k, v)
0 1
1 <built-in function print>
2 2
3 Ahoj!
4 [1, 2, '3']
>>> xs
39: {0: 1, 1: <built-in function print>, 2: 2, 3: 'Ahoj!', 4: [1, 2, '3']}
>>> xs[5]
Traceback (most recent call last):
File "<pyshell#76>", line 1, in <module>
xs[5]
KeyError: 5
>>> xs.get(4)
40: [1, 2, '3']
>>> xs.get(5)
>>> xs.get(5, 'Neexistující klíč!')
41: 'Neexistující klíč!'
>>> str([1, 2, 'ahoj', 3])
42: "[1, 2, 'ahoj', 3]"
>>> dir([1, 2, 'ahoj', 3])
43: ['__add__',
'__class__',
'__class_getitem__',
'__contains__',
'__delattr__',
'__delitem__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
'__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 46 more lines. Double-click to unfold]
>>> [1, 2, 'ahoj', 3].__str__()
44: "[1, 2, 'ahoj', 3]"
>>> 'a' in 'ahoj'
45: True
>>> 'ah' in 'ahoj'
46: True
>>> 'ah' not in 'ahoj'
47: False
>>> 'A' not in 'ahoj'
48: True
>>> '+'*10
49: '++++++++++'
>>> 10*'+'
50: '++++++++++'
>>> 'ahoj' and 333
51: 333
>>> [] and 333
52: []
>>> 'ahoj' or []
53: 'ahoj'
>>> [] or 'ahoj'
54: 'ahoj'
>>> bool('ahoj')
55: True
>>> bool('')
56: False
>>> bool(None)
57: False
>>> bool(fn)
58: True
>>> fn
59: <function fn at 0x000001C46D2C9F30>
>>> True + True
60: 2
>>> True and True
61: True
>>> True + False
62: 1
>>> int(False)
63: 0
>>> int(True)
64: 1
>>> x = y = 'a'
>>> x
65: 'a'
>>> y
66: 'a'
>>> id(x)
67: 1943156662960
>>> id(y)
68: 1943156662960
>>> x = 'b'
>>> x
69: 'b'
>>> y
70: 'a'
>>> xs = [1, 2, 3]
>>> ys = xs
>>> ys
71: [1, 2, 3]
>>> xs[0] = 'a'
>>> xs
72: ['a', 2, 3]
>>> ys
73: ['a', 2, 3]
>>> for x in range(333):
... print(chr(x), 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 { | } ~
¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ® ¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ Ā ā Ă ă Ą ą Ć ć Ĉ ĉ Ċ ċ Č č Ď ď Đ đ Ē ē Ĕ ĕ Ė ė Ę ę Ě ě Ĝ ĝ Ğ ğ Ġ ġ Ģ ģ Ĥ ĥ Ħ ħ Ĩ ĩ Ī ī Ĭ ĭ Į į İ ı IJ ij Ĵ ĵ Ķ ķ ĸ Ĺ ĺ Ļ ļ Ľ ľ Ŀ ŀ Ł ł Ń ń Ņ ņ Ň ň ʼn Ŋ ŋ Ō
>>> sorted('xoňpn')
74: ['n', 'o', 'p', 'x', 'ň']
>>>