80 lines
1.1 KiB
Markdown
80 lines
1.1 KiB
Markdown
# Exercices
|
|
|
|
## Exercice 1
|
|
|
|
```python
|
|
roll = 5
|
|
if roll > 4:
|
|
print("Lancer réussi !")
|
|
```
|
|
|
|
## Exercice 2
|
|
|
|
```python
|
|
text = "Bonjour"
|
|
if text == "bonjouR":
|
|
print("Bien le bonjour")
|
|
```
|
|
|
|
## Exercice 2B
|
|
|
|
```python
|
|
text = "Bonjour"
|
|
if text == "Bonjour":
|
|
print("Bien le bonjour")
|
|
else:
|
|
print("Je ne comprends pas !")
|
|
```
|
|
|
|
## Exercice 3
|
|
|
|
```python
|
|
value = 7
|
|
if value >= 9:
|
|
print("Élevé")
|
|
elif value >= 7:
|
|
print("Haut")
|
|
elif value >= 4:
|
|
print("Standard")
|
|
else:
|
|
print("Bas")
|
|
```
|
|
|
|
## Exercice A1
|
|
|
|
```python
|
|
a1 = 4
|
|
a2 = 7
|
|
if a1 > 5 and a2 < 6:
|
|
print("OK")
|
|
else:
|
|
print("Valeurs incorrectes")
|
|
```
|
|
|
|
## Exercice A2
|
|
|
|
```python
|
|
a1 = 5
|
|
a2 = 5
|
|
if a1 > 5 or a2 < 6:
|
|
print("Conditions suffisantes")
|
|
else:
|
|
print("Valeurs incorrectes")
|
|
```
|
|
|
|
## Exercice A3
|
|
|
|
```python
|
|
is_on = True
|
|
saisie = input("Saisissez une commande (Marche ou Arrêt) :")
|
|
if saisie == "Marche":
|
|
if is_on is False:
|
|
print("Allumage en cours…")
|
|
else:
|
|
print("Déjà allumé !")
|
|
elif saisie == "Arrêt":
|
|
if is_on:
|
|
print("Extinction…")
|
|
else:
|
|
print("Déjà éteint !")
|
|
``` |