« Python : Les variables » : différence entre les versions
De www.yakakliker.org
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 34 : | Ligne 34 : | ||
POSTGRES_PASSWORD=XXXXX | POSTGRES_PASSWORD=XXXXX | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Les types de variable == | |||
{| class="wikitable" | |||
|'''Type''' | |||
|'''Nom Python''' | |||
|'''Exemple''' | |||
|'''Description''' | |||
|- | |||
|'''Entier''' | |||
|<code>int</code> | |||
|<code>age = 25</code> | |||
|Nombres sans virgule. | |||
|- | |||
|'''Flottant''' | |||
|<code>float</code> | |||
|<code>prix = 19.99</code> | |||
|Nombres avec virgule (utilisez un point <code>.</code>). | |||
|- | |||
|'''Chaîne''' | |||
|<code>str</code> | |||
|<code>nom = "Alice"</code> | |||
|Texte entouré de guillemets. | |||
|- | |||
|'''Booléen''' | |||
|<code>bool</code> | |||
|<code>est_pret = True</code> | |||
|Vrai ou Faux (<code>True</code> ou <code>False</code>). | |||
|} | |||
=== Liens === | === Liens === | ||
https://dyma.fr/developer/list/chapters/core/619556fdd5fe7e09d4aba395/lesson/python/61969e5866ef0d5e68f7f66d/2/2 | https://dyma.fr/developer/list/chapters/core/619556fdd5fe7e09d4aba395/lesson/python/61969e5866ef0d5e68f7f66d/2/2 | ||
[[Catégorie:Python]] | [[Catégorie:Python]] | ||
[[Catégorie:Scripts]] | [[Catégorie:Scripts]] | ||
<html> | |||
<a href="https://www.compteurdevisite.com" title="compteur web gratuit sans pub"><img src="https://counter6.optistats.ovh/private/compteurdevisite.php?c=b4epghealnwlf7wuq7gn3ygll9aywrfx" border="0" title="compteur web gratuit sans pub" alt="compteur web gratuit sans pub"></a> | <a href="https://www.compteurdevisite.com" title="compteur web gratuit sans pub"><img src="https://counter6.optistats.ovh/private/compteurdevisite.php?c=b4epghealnwlf7wuq7gn3ygll9aywrfx" border="0" title="compteur web gratuit sans pub" alt="compteur web gratuit sans pub"></a> | ||
</html> | </html> | ||
Version du 20 janvier 2026 à 14:33
Déclarer une variable
nom_de_la_variable = uneValeur
Afficher une variable
variable = 'Bonjour tout le monde'
print(variable)
Types de variables
Variables stockées dans un fichier externe (ex : .env)
db_user = os.getenv('POSTGRES_USER')
db_password = os.getenv('POSTGRES_PASSWORD')
db_host = os.getenv('POSTGRES_HOST')
db_port = os.getenv('POSTGRES_PORT')
db_name = os.getenv('POSTGRES_DB')
db_schema = os.getenv('POSTGRES_SCHEMA')
- Dans le fichier :
POSTGRES_HOST=XXXXX
POSTGRES_PORT=XXXXX
POSTGRES_DB=XXXXX
POSTGRES_USER=XXXXX
POSTGRES_SCHEMA=XXXXX
POSTGRES_PASSWORD=XXXXX
Les types de variable
| Type | Nom Python | Exemple | Description |
| Entier | int
|
age = 25
|
Nombres sans virgule. |
| Flottant | float
|
prix = 19.99
|
Nombres avec virgule (utilisez un point .).
|
| Chaîne | str
|
nom = "Alice"
|
Texte entouré de guillemets. |
| Booléen | bool
|
est_pret = True
|
Vrai ou Faux (True ou False).
|