Exercices Python
This commit is contained in:
parent
34c54eea8c
commit
7e1a478b23
8
sio2/sisr/python/ex1.py
Executable file
8
sio2/sisr/python/ex1.py
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
pi=3.141592
|
||||||
|
r=int(input("Veuillez renseigner la valeur du rayon du cercle : "))
|
||||||
|
p=2*pi*r
|
||||||
|
|
||||||
|
print("Le périmètre vaut: ", p)
|
||||||
|
|
27
sio2/sisr/python/ex2.py
Executable file
27
sio2/sisr/python/ex2.py
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
#Creation du tableau
|
||||||
|
|
||||||
|
i=0
|
||||||
|
tab=[]
|
||||||
|
total = 0
|
||||||
|
|
||||||
|
for i in range (5):
|
||||||
|
valeur = int(input("Entrez la valeur du tableau : "))
|
||||||
|
tab.append(valeur)
|
||||||
|
print(tab)
|
||||||
|
|
||||||
|
l = len(tab)
|
||||||
|
|
||||||
|
maxi = tab[0]
|
||||||
|
mini = tab[0]
|
||||||
|
moyenne = 0
|
||||||
|
|
||||||
|
for i in range (0,l):
|
||||||
|
if mini > tab[i]:
|
||||||
|
mini = tab[i]
|
||||||
|
if maxi < tab[i]:
|
||||||
|
maxi = tab[i]
|
||||||
|
total = tab[i]+total
|
||||||
|
moyenne = total /(i+1)
|
||||||
|
|
||||||
|
print("Le maximum : ", maxi,", le minimum : ", mini,", la moyenne : ", moyenne,", le total : ",total, ".")
|
15
sio2/sisr/python/ex3.py
Executable file
15
sio2/sisr/python/ex3.py
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
phrase = input("Phrase: ")
|
||||||
|
tabmot=phrase.split (' ')
|
||||||
|
cptmot={}
|
||||||
|
|
||||||
|
for mot in tabmot:
|
||||||
|
if mot in cptmot:
|
||||||
|
cptmot[mot]=cptmot[mot]+1
|
||||||
|
else :
|
||||||
|
cptmot[mot]=1
|
||||||
|
|
||||||
|
for cle in cptmot.keys():
|
||||||
|
print(cle, cptmot[cle])
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user