2022-10-13 21:12:48 +02:00
|
|
|
Pierre Valarcher
|
|
|
|
|
|
|
|
pierre.valarcher@u-pec.fr
|
|
|
|
|
|
|
|
object : [ Master TNT ] izerfhzoeirf
|
|
|
|
|
|
|
|
Langage de programmation
|
|
|
|
|
|
|
|
3000 langages
|
|
|
|
|
|
|
|
+ Python + nombreuses librairies
|
|
|
|
Syntaxe
|
|
|
|
Sémantique opérationnelle
|
|
|
|
Sémantique dénotationnelle
|
|
|
|
|
2022-10-26 14:07:56 +02:00
|
|
|
```python
|
2022-10-13 21:12:48 +02:00
|
|
|
for i in (1 .. 100):
|
|
|
|
print ("Je ne lance plus d'avion dans la classe")
|
2022-10-13 21:28:48 +02:00
|
|
|
```
|
2022-10-13 21:12:48 +02:00
|
|
|
|
|
|
|
REPL
|
|
|
|
Read Eval Print Loop
|
|
|
|
|
|
|
|
Pomme
|
|
|
|
|
|
|
|
+ C
|
|
|
|
+ Rust
|
|
|
|
Java
|
|
|
|
C++
|
|
|
|
Javascript
|
|
|
|
Ruby
|
|
|
|
R
|
|
|
|
|
|
|
|
|
|
|
|
HTML
|
|
|
|
CSS
|
|
|
|
|
|
|
|
|
|
|
|
## Variable
|
|
|
|
Stockage d'information. On nomme des valeurs
|
|
|
|
Dans les langages il y a des mots réservés : if, else, for, while, +, -, =, :
|
|
|
|
n+m
|
|
|
|
|
|
|
|
lettres et chiffres : commence tjs par une lettre
|
|
|
|
if0 : Ok
|
|
|
|
|
|
|
|
Le plus souvent un nom de variable va porter sa sémantique.
|
|
|
|
temperature : ok
|
|
|
|
n, m repsentent des entiers
|
|
|
|
x, y représentent des réels
|
|
|
|
i, j comme des entiers
|
|
|
|
|
|
|
|
|
|
|
|
## Expression
|
|
|
|
|
|
|
|
C'est le calcul d'une valeur :
|
|
|
|
3 + 4 => 7 (se reduit à)
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
## Affectation (assignment)
|
|
|
|
|
2022-10-13 21:28:48 +02:00
|
|
|
```
|
2022-10-13 21:12:48 +02:00
|
|
|
nom_variable = expression
|
2022-10-13 21:28:48 +02:00
|
|
|
```
|
2022-10-13 21:12:48 +02:00
|
|
|
|
|
|
|
Expression ca a une valeur
|
|
|
|
|
|
|
|
## Type : Domaine
|
|
|
|
|
2022-10-13 21:28:48 +02:00
|
|
|
```
|
2022-10-13 21:12:48 +02:00
|
|
|
f : N -> N fonction
|
|
|
|
: n -> n*2
|
|
|
|
|
|
|
|
f(5) => 10
|
|
|
|
|
|
|
|
+ : N, N -> N
|
|
|
|
n, m -> la somme de n et de m
|
|
|
|
|
|
|
|
3 + 4 => 7
|
2022-10-13 21:28:48 +02:00
|
|
|
```
|
2022-10-13 21:12:48 +02:00
|
|
|
|
|
|
|
Entier (int, integer) : 16, -16
|
|
|
|
Réel (float, double) : 16.2, PI, e (exponentiel), 1/3
|
|
|
|
|
|
|
|
Fini
|
|
|
|
|
|
|
|
Caractère : 'r', '2',
|
|
|
|
Chaine de caractères : "r2", "r", "r 2", "r2"
|
|
|
|
Booléen :
|
|
|
|
|
|
|
|
## Structure de controle : Sequence
|
|
|
|
Une suite de quelquechose : un saut de ligne
|
|
|
|
|
|
|
|
## Structure de controle : conditionnelle
|
|
|
|
|
2022-10-13 21:28:48 +02:00
|
|
|
```
|
2022-10-13 21:12:48 +02:00
|
|
|
if condition:
|
|
|
|
bloc_instruction1
|
|
|
|
else:
|
|
|
|
bloc_instruction2
|
2022-10-13 21:28:48 +02:00
|
|
|
```
|
|
|
|
|
2022-10-13 21:12:48 +02:00
|
|
|
symbole de comparaison
|
2022-10-13 21:28:48 +02:00
|
|
|
```
|
2022-10-13 21:12:48 +02:00
|
|
|
<, >, <=, >=, ==, !=
|
2022-10-13 21:28:48 +02:00
|
|
|
```
|
2022-10-13 21:12:48 +02:00
|
|
|
operateurs logiques
|
2022-10-13 21:28:48 +02:00
|
|
|
```
|
2022-10-13 21:12:48 +02:00
|
|
|
and, or
|
2022-10-13 21:28:48 +02:00
|
|
|
```
|
2022-10-13 21:12:48 +02:00
|
|
|
|
2022-10-13 21:28:48 +02:00
|
|
|
```
|
2022-10-13 21:12:48 +02:00
|
|
|
if (age < 40) and (prenom=="Pierre"):
|
2022-10-13 21:28:48 +02:00
|
|
|
```
|
2022-10-13 21:12:48 +02:00
|
|
|
|
|
|
|
## Structure de controle : itération
|
|
|
|
|
2022-10-13 21:28:48 +02:00
|
|
|
```
|
2022-10-13 21:12:48 +02:00
|
|
|
for i in range(1, 10):
|
|
|
|
bloc
|
2022-10-13 21:28:48 +02:00
|
|
|
```
|
2022-10-13 21:12:48 +02:00
|
|
|
|
|
|
|
range(1,10) correspond à une séquence de nombre de 1 à 9.
|
|
|
|
|