list('ctx')
['c', 't', 'x']
list((1,2,3))
[1, 2, 3]
tuple('ctx')
('c', 't', 'x')
tuple((1,2,3))
(1, 2, 3)
tuple([1,2,3])
(1, 2, 3)
str([1,2])
'[1, 2]'
str((1,3))
'(1, 3)'
s=[1,1,2,3,5]
min(s)
1
t='ctx'
max(t)
'x'
t='Cc'
max(t)
'c'
s=[]
max(s)
Traceback (most recent call last):
File "<pyshell#14>", line 1, in <module>
max(s)
ValueError: max() arg is an empty sequence
min(s,'sdfds')
Traceback (most recent call last):
File "<pyshell#19>", line 1, in <module>
min(s,'sdfds')
TypeError: '<' not supported between instances of 'str' and 'list'
min(s,default='sdfds')
'sdfds'
len(range(2**333))
Traceback (most recent call last):
File "<pyshell#21>", line 1, in <module>
len(range(2**333))
OverflowError: Python int too large to convert to C ssize_t
s=[1,2,5]
sum(s)
8
sum(s,start=13)
21
s=[1,3,2,8,4]
sorted(s)
[1, 2, 3, 4, 8]
s
[1, 3, 2, 8, 4]
s.sort()
s
[1, 2, 3, 4, 8]
s=[1,5,2,8,4]
sorted(s,reverse=True)
[8, 5, 4, 2, 1]
s=[1,5,2,8,4]
sorted(s,reverse=False)
[1, 2, 4, 5, 8]
a=['ads','fgh','ervx','Ervx','ERvx']
sorted(a)
['ERvx', 'Ervx', 'ads', 'ervx', 'fgh']
sorted(a,len(s))
Traceback (most recent call last):
File "<pyshell#36>", line 1, in <module>
sorted(a,len(s))
TypeError: sorted expected 1 argument, got 2
sorted(a,key=len)
['ads', 'fgh', 'ervx', 'Ervx', 'ERvx']
sorted('Ctx')
['C', 't', 'x']
sorted('zqy')
['q', 'y', 'z']
sorted(1,0,0,8,6)
Traceback (most recent call last):
File "<pyshell#40>", line 1, in <module>
sorted(1,0,0,8,6)
TypeError: sorted expected 1 argument, got 5
sorted((1,0,0,8,6))
[0, 0, 1, 6, 8]
s=[1,3,7,8,5]
reversed(s)
<list_reverseiterator object at 0x103861720>
list(reversed(s))
[5, 8, 7, 3, 1]
s.reverse()
s
[5, 8, 7, 3, 1]
list(reversed("FishC"))
['C', 'h', 's', 'i', 'F']
tuple(reversed("FishC"))
('C', 'h', 's', 'i', 'F')
list(reversed((1, 2, 5, 9, 3)))
[3, 9, 5, 2, 1]
tuple(reversed((1, 2, 5, 9, 3)))
(3, 9, 5, 2, 1)
list(reversed(range(0, 10)))
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
tuple(reversed(range(0, 10)))
(9, 8, 7, 6, 5, 4, 3, 2, 1, 0) |