Skip to content

Commit

Permalink
maj
Browse files Browse the repository at this point in the history
  • Loading branch information
glassus committed Jan 16, 2025
1 parent 18641e9 commit d7cfe4d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
33 changes: 33 additions & 0 deletions docs/T1_Structures_de_donnees/1.2_Dictionnaires/exercices.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,39 @@

{{initexo(0)}}

!!! example "{{ exercice() }}"
On considère la liste suivante :
```lst = ['5717', '1133', '5545', '4031', '6398', '2734', '3070', '1346', '7849', '7288', '7587', '6217', '8240', '5733', '6466', '7972', '7341', '6616', '5061', '2441', '2571', '4496', '4831', '5395', '8584', '3033', '6266', '2452', '6909', '3021', '5404', '3799', '5053', '8096', '2488', '8519', '6896', '7300', '5914', '7464', '5068', '1386', '9898', '8313', '1072', '1441', '7333', '5691', '6987', '5255']```

Quel est le **chiffre** qui revient le plus fréquemment dans cette liste ?

{{
correction(False,
"""
??? success \"Correction\"
```python linenums='1'
lst = ['5717', '1133', '5545', '4031', '6398', '2734', '3070', '1346', '7849', '7288', '7587', '6217', '8240', '5733', '6466', '7972', '7341', '6616', '5061', '2441', '2571', '4496', '4831', '5395', '8584', '3033', '6266', '2452', '6909', '3021', '5404', '3799', '5053', '8096', '2488', '8519', '6896', '7300', '5914', '7464', '5068', '1386', '9898', '8313', '1072', '1441', '7333', '5691', '6987', '5255']

occ = {}
maxi = 0
for nombre in lst:
for chiffre in nombre:
if chiffre in occ:
occ[chiffre] += 1
else:
occ[chiffre] = 1
if occ[chiffre] > maxi:
maxi = occ[chiffre]
chiffre_max = chiffre

print(chiffre_max, 'est le chiffre le plus fréquent')
print('il apparait', maxi, 'fois')

```
"""
)
}}



Expand Down
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@


!!! note ":star: Thèmes en cours d'étude :star: "
- [Dictionnaires : cours](T1_Structures_de_donnees/1.2_Dictionnaires/cours/)
- [Dictionnaires : exercices](T1_Structures_de_donnees/1.2_Dictionnaires/exercices/)
- [Protocoles de routage : exercices](T5_Architecture_materielle/5.3_Protocoles_de_routage/exercices/)
- [Protocoles de routage : cours](T5_Architecture_materielle/5.3_Protocoles_de_routage/cours/)
- [Arbres : exercices](T1_Structures_de_donnees/1.3_Arbres/exercices/)
Expand Down

0 comments on commit d7cfe4d

Please sign in to comment.