Skip to content

Commit

Permalink
maj
Browse files Browse the repository at this point in the history
  • Loading branch information
glassus committed Oct 17, 2023
1 parent 59841b3 commit 042fb5d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions docs/T1_Demarrer_en_Python/1.5_Fonctions/exercices.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@


=== "Correction"
{{ correction(False,
{{ correction(True,
"
```python linenums='1'
def decale(lettre, n):
Expand Down Expand Up @@ -236,7 +236,7 @@
```

=== "Correction"
{{ correction(False,
{{ correction(True,
"
```python linenums='1'
def decale_phrase(p, n):
Expand All @@ -259,14 +259,17 @@
Décodez la phrase `RT BTHHPVT CT RDCIXTCI GXTC S XCITGTHHPCI`.

=== "Correction"
{{ correction(False,
{{ correction(True,
"
```python linenums='1'
def decale(lettre, n):
rang_ancienne_lettre = ord(lettre) - 65
rang_nouvelle_lettre = (rang_ancienne_lettre + n) % 26 + 65
rang_lettre = ord(lettre)
rang_nouvelle_lettre = rang_lettre + n
if rang_nouvelle_lettre > ord('Z'):
rang_nouvelle_lettre -= 26
nouvelle_lettre = chr(rang_nouvelle_lettre)

return chr(rang_nouvelle_lettre)
return nouvelle_lettre

def decale_phrase(p, n):
phrase_decalee = ''
Expand Down

0 comments on commit 042fb5d

Please sign in to comment.