__builtins__
bool([value])
object.index(value, [start, [stop]])
list.insert(index, object)
int(x=0, base=10)
len(object)
max(iterable[, key=func])
ou max(a, b, c, ...[, key=func])
min(iterable[, key=func])
ou min(a, b, c, ...[, key=func])
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
range(stop)
ou range(start, stop[, step])
template.format(p1, p1, .... , k1=v1, k2=v2)
type(object)
__main__
list.append(object)
object.count(value)
ou string.count(sub[, start[, end]])
string.lower()
list.remove(value)
list.reverse()
string.split(sep=None, maxsplit=-1)
string.upper()
__builtins__
bool([value])
>>> test = [] >>> print(test,'is',bool(test)) [] is False >>> test = [0] >>> print(test,'is',bool(test)) [0] is True >>> test = 0.0 >>> print(test,'is',bool(test)) 0.0 is False >>> test = None >>> print(test,'is',bool(test)) None is False >>> test = True >>> print(test,'is',bool(test)) True is True >>> test = 'Easy string' >>> print(test,'is',bool(test)) Easy string is True
object.index(value, [start, [stop]])
object peut être du type : list, tuple, string
>>> [1,2,3,4,5,6,7,8,9,10].index(3) 2 >>> [1,2,3,4,5,6,7,8,9,10].index(8, 0, 5) Traceback (most recent call last): File "", line 1, in ValueError: 8 is not in list >>> [1,2,3,4,5,6,7,8,9,10].index(8, 5, 9) 7
list.insert(index, object)
>>> test = [1,2,3,4,5,6,7,8,9,10] >>> test.insert(3, 444) >>> test [1, 2, 3, 444, 4, 5, 6, 7, 8, 9, 10] >>> test.insert(8, 'essai') >>> test [1, 2, 3, 444, 4, 5, 6, 7, 'essai', 8, 9, 10]
int(x=0, base=10)
>>> print("int(101) is:", int(101)) int(101) is: 101 >>> print("int(101.23) is:", int(101.23)) int(101.23) is: 101 >>> print("int('101') is:", int('101')) int('101') is: 101 >>> print("int('101',2) base 2 is:", int('101', 2)) int('101',2) base 2 is: 5 >>> print("int('101',8) base 8 is:", int('101', 8)) int('101',8) base 8 is: 65 >>> print("int('101',16) base 16 is:", int('101', 16)) int('101',16) base 16 is: 257
len(object)
>>> len('azerty') 6 >>> len([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) 10 >>> len(((1,2), (2,3), (3,4))) 3 >>> len({1 : "truc", 2 : "machin", 3 : "bidule"}) 3 >>> len(range(12, 16)) 4
max(iterable[, key=func])
max(a, b, c, ...[, key=func])
>>> max([12.7,89,453,4,56]) 453 >>> max(12.7,89,453,4,56) 453
min(iterable[, key=func])
min(a, b, c, ...[, key=func])
>>> min([12.7,89,453,4,56]) 4 >>> min(12.7,89,453,4,56) 4
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
>>> print("John","Doe","30") John Doe 30 >>> print("John","Doe","30", sep="->", end='*\n') John->Doe->30*
range(stop)
range(start, stop[, step])
>>> range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> range(30, 100, 10) [30, 40, 50, 60, 70, 80, 90]
template.format(p1, p1, .... , k1=v1, k2=v2)
>>> 'Sam has {} red balls and {} yellow balls'.format(12, 31) 'Sam has 12 red balls and 31 yellow balls' >>> 'Sam has {0} red balls and {1} yellow balls'.format(12, 31) 'Sam has 12 red balls and 31 yellow balls' >>> 'Sam has {1} red balls and {0} yellow balls'.format(12, 31) 'Sam has 31 red balls and 12 yellow balls'
type(object)
Retourne le type de l’objet spécifié.
>>> a = (1,2,3) >>> b = [1,2,3] >>> type(a) <class 'tuple'> >>> type(b) <class 'list'> >>> type([1,2,3]) <class 'list'>
__main__
list.append(object)
>>> test = [1,2,3,4,5,6,7,8,9,10] >>> test.append(11) >>> test [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] >>> test.append('fin') >>> test [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 'fin']
object.count(value)
string.count(sub[, start[, end]])
object peut être du type : list, tuple
string.lower()
>>> ['a', ('a', 'b'), ('a', 'b'), [3, 4]].count('a') 1 >>> ['a', ('a', 'b'), ('a', 'b'), [3, 4]].count(('a','b')) 2 >>> ['a', ('a', 'b'), ('a', 'b'), [3, 4]].count('z') 0 >>> 'Cuitas les bananas'.count('a') 4 >>> 'Cuitas les bananas'.count('a', 10) 3 >>> 'Cuitas les bananas'.count('a', 10, 15) 2
string.lower()
>>> print("THIS SHOULD BE LOWERCASE!".lower()) this should be lowercase! >>> print("Th!s Sh0uLd B3 L0w3rCas3!!".lower()) th!s sh0uld b3 l0w3rcas3!!
list.remove(value)
>>> test = ['b','a','n','a','n','a','s'] >>> test.remove('a') >>> test ['b', 'n', 'a', 'n', 'a', 's']
list.reverse()
>>> test = ['b','a','n','a','n','a','s'] >>> test ['b', 'a', 'n', 'a', 'n', 'a', 's'] >>> test.reverse() >>> test ['s', 'a', 'n', 'a', 'n', 'a', 'b']
string.split(sep=None, maxsplit=-1)
>>> '1,2,3'.split(',') ['1', '2', '3'] >>> '1,2,3'.split(',', maxsplit=1) ['1', '2,3'] >>> '1,2,,3,'.split(',') ['1', '2', '', '3', '']
>>> '1 2 3'.split() ['1', '2', '3'] >>> '1 2 3'.split(maxsplit=1) ['1', '2 3'] >>> ' 1 2 3 '.split() ['1', '2', '3']
string.upper()
>>> print("this should be uppercase!".upper()) THIS SHOULD BE UPPERCASE! >>> print("Th!s Sh0uLd B3 uPp3rCas3!".upper()) TH!S SH0ULD B3 UPP3RCAS3!