Ajout premiere seance
This commit is contained in:
parent
b5de1f961c
commit
b97b4bc1e6
|
@ -0,0 +1,147 @@
|
|||
---
|
||||
title: "Initiation Python - séance 1"
|
||||
author: "VireGul - viregul.fr"
|
||||
description: Initiation à la programmation Python
|
||||
lang: fr
|
||||
type: slide
|
||||
slideOptions:
|
||||
transition: slide
|
||||
theme: black
|
||||
mouseWheel: true
|
||||
---
|
||||
|
||||
# Initiation Python - séance 1/5
|
||||
|
||||
## Environnement Python et Variables
|
||||
|
||||
|
||||
*[Association VireGul](https://viregul.fr)*
|
||||
|
||||
---
|
||||
|
||||
## Système Python
|
||||
|
||||
* Version 3 : ```python --version```
|
||||
* Syntaxe simple
|
||||
* ! Identation
|
||||
* Mode console ou script python
|
||||
* Environnements virtuels
|
||||
* Nombreux modules externes
|
||||
* Nombreuses ressources
|
||||
|
||||
----
|
||||
|
||||
## Ressources Internet
|
||||
|
||||
* [Cours OpenClassroom](https://openclassrooms.com/fr/courses/235344-apprenez-a-programmer-en-python) (40h)
|
||||
* [Apprendre à programmer avec Python 3 (CC)](https://inforef.be/swi/python.htm)
|
||||
* [python.developpez.com](https://python.developpez.com/)
|
||||
* Tutos Vidéos : [Koor.fr](https://koor.fr/Python/Tutos.wp)
|
||||
* [Dès le lycée (2nd STI)](http://python.lycee.free.fr/)
|
||||
* [Mooc pour débutants](http://flot.sillages.info/?portfolio=flot-programmation-pour-debutants)
|
||||
|
||||
----
|
||||
|
||||
## Exemples
|
||||
|
||||
#### Lancement en console
|
||||
|
||||
```
|
||||
$ python3
|
||||
>>>
|
||||
>>> Ctrl + D (sortie)
|
||||
```
|
||||
|
||||
#### Lancement d'un script
|
||||
|
||||
```
|
||||
$ python3 monscript.py
|
||||
$ ./monscript.py (si contient l'entête python)
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
## Conventions
|
||||
|
||||
* *variables* : minuscule
|
||||
* *CONSTANTES* : MAJUSCULE
|
||||
|
||||
* *Méthodes, modules* : minuscule (fonctions, change_valeur)
|
||||
|
||||
* *Programmation Objet* : ClasseObjet
|
||||
|
||||
```python
|
||||
# Ceci est un commentaire
|
||||
!!! Sensible à la casse
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Variables
|
||||
### Types de données
|
||||
|
||||
```python
|
||||
entier : age = 48
|
||||
nombre flottant : taille = 1.78
|
||||
chaine : nom = "Audirac"
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
## Opérateurs
|
||||
|
||||
* *Nombres* : + - * /
|
||||
* *Chaines* : + (concaténation)
|
||||
|
||||
### Fonction print
|
||||
|
||||
```python
|
||||
print("Ton nom",varnom," ton âge",varage)
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
## Variables complexes
|
||||
|
||||
### Listes
|
||||
```python
|
||||
maliste = [1, "moi", 3.5 , [48,25]]
|
||||
maliste[2]
|
||||
nom[2:5]
|
||||
```
|
||||
|
||||
**Attention !**
|
||||
|
||||
```python
|
||||
liste2 = maliste # pas de copie, même référence.
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
## Variables complexes
|
||||
### Tuples (peu utilisé)
|
||||
|
||||
* liste non modifiable
|
||||
* montuple = (1,"ok",34.5,["A",2])
|
||||
|
||||
### Dictionnaires
|
||||
|
||||
Liste non ordonnée de clefs : valeur
|
||||
|
||||
```python
|
||||
moi = { 'nom': "Audirac", 'prenom': "François" }
|
||||
moi['nom']
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Premier programme
|
||||
|
||||
```python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
reponse=input('question')
|
||||
print(reponse)
|
||||
```
|
||||
|
||||
**Exercices** : Faire des calculs, poser des questions, créer des listes...
|
Loading…
Reference in New Issue