This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Exemple de noms de variables et leur d'affectation | |
email = "contact@datascientest.com" | |
_id = 100 | |
statut_verifie = False | |
# La valeur d'une variable peut être modifiée après l'affectation | |
age = 24 | |
age = 25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Les Entiers | |
>>> 1 + 41 | |
42 | |
>>> a = 4 | |
>>> type(a) | |
<type 'int'> | |
# Les Décimaux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> s = 'Hello, how are you?' | |
>>> s = "Hi, what's up" | |
# Le fait de tripler les guillemets permet à la chaîne | |
# de s'étendre sur plus d'une ligne | |
>>> s = '''Hello, | |
how are you''' | |
>>> s = """Hi, | |
what's up?""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> a = "hello, world!" | |
>>> a.replace('l', 'z', 1) | |
'hezlo, world!' | |
>>> a.replace('l', 'z') | |
'hezzo, worzd!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> 3 > 4 | |
False | |
>>> test = (3 > 4) | |
>>> test | |
False | |
>>> type(test) | |
<type 'bool'> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> False == (not True) | |
True | |
>>> 1.41 < 2.71 and 2.71 < 3.14 | |
True | |
# On peut egalement ecrire | |
>>> 1.41 < 2.71 < 3.14 | |
>>> x = False | |
>>> y = True | |
>>> x or y | |
True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> colors = ['red', 'blue', 'green', 'black', 'white'] | |
>>> type(colors) | |
<type 'list'> | |
# Indexation : accès aux objets individuels contenus dans la liste: | |
>>> colors[2] | |
'green' | |
# Comptage à partir de la fin avec des indices négatifs: | |
>>> colors[-1] | |
'white' | |
>>> colors[-2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> t = ('une phrase', 3.14, 'c', 2) | |
>>> tt | |
('une phrase', 3.14, 'c', 2) | |
>>> tt[1] | |
3.14 | |
# On ne peut pas changer un tuple, on dit qu'il est immuable: | |
>>> t[0] = 1 | |
Error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> s = {1, 2, 2, 2, 3, 3, 'DataScientest', 'Datascience', 'Python'} | |
>>> s | |
{1, 2, 3, 'DataScientest', 'Datascience', 'Python'} | |
>>> set('DataScientest') | |
{'e', 'n', 'D', 'a', 't', 'i', 'S', 's', 'c'} | |
>>> {1, 5, 2, 1, 1}.union({1, 2, 3}) | |
{1, 2, 3, 5} | |
>>> set([1, 5, 2, 1, 1]).intersection(set([1, 2, 3])) | |
{1, 2} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> formations_id = {'DATA SCIENTIST': 1, 'DATA ANALYST': 2, 'DATA ENGINEER': 3} | |
>>> print(formations_id) | |
{'DATA SCIENTIST': 1, 'DATA ANALYST': 2, 'DATA ENGINEER': 3} | |
>>> print(type(formations_id)) | |
<class 'dict'> | |
>>> formations_id['DATA ENGINEER'] | |
3 | |
>>> formations_id['DATA MANAGEMENT'] = 4 | |
>>> formations_id | |
{'DATA SCIENTIST': 1, 'DATA ANALYST': 2, 'DATA ENGINEER': 3, 'DATA MANAGEMENT': 4} |
OlderNewer