Skip to content

Instantly share code, notes, and snippets.

View gtordjma's full-sized avatar
🏠
Working from home

gtordjma

🏠
Working from home
View GitHub Profile
@gtordjma
gtordjma / python-exemple_variables.py
Last active November 4, 2020 08:58
Python - Exemple Variables
# 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
@gtordjma
gtordjma / python-exemple_types_numeriques.py
Created November 4, 2020 09:00
Python - Exemple Types Numériques
# Les Entiers
>>> 1 + 41
42
>>> a = 4
>>> type(a)
<type 'int'>
# Les Décimaux
@gtordjma
gtordjma / python-exemple_string1.py
Created November 4, 2020 09:02
Python - Exemple String
>>> 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?"""
@gtordjma
gtordjma / python-exemple_string2.py
Created November 4, 2020 09:03
Python - Exemple String
>>> a = "hello, world!"
>>> a.replace('l', 'z', 1)
'hezlo, world!'
>>> a.replace('l', 'z')
'hezzo, worzd!'
@gtordjma
gtordjma / python-exemple_bool1.py
Created November 4, 2020 09:06
Python - Exemple Bool
>>> 3 > 4
False
>>> test = (3 > 4)
>>> test
False
>>> type(test)
<type 'bool'>
@gtordjma
gtordjma / python-exemple_bool2.py
Created November 4, 2020 09:06
Python - Exemple Bool
>>> 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
@gtordjma
gtordjma / python-exemple_list.py
Created November 4, 2020 09:08
Python - Exemple List
>>> 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]
@gtordjma
gtordjma / python-exemple_tuple.py
Created November 4, 2020 09:09
Python- Exemple Tuple
>>> 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
@gtordjma
gtordjma / python-exemple_set.py
Created November 4, 2020 09:10
Python - Exemple Set
>>> 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}
@gtordjma
gtordjma / python-exemple_dict1.py
Created November 4, 2020 09:13
Python - Exemple Dict
>>> 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}