-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex4.py
More file actions
32 lines (29 loc) · 749 Bytes
/
ex4.py
File metadata and controls
32 lines (29 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def compterMots(texte):
dict = {}
listeMots = texte.split()
for mot in listeMots:
if mot in dict:
dict[mot] = dict[mot] + 1
else:
dict[mot] = 1
return dict
# programme principal -----------------------------------------------
res = compterMots("Ala Met Asn Glu Met Cys Asn Glu Hou Ala Met Gli Asn Asn")
for c in res.keys():
print(c, "-->", res[c])
# import
from math import sqrt
# fonction
def trinome(a, b, c):
delta = b**2 - 4*a*c
if delta > 0.0:
racine_delta = sqrt(delta)
return (2, (-b-racine_delta)/(2*a), (-b+racine_delta)/(2*a))
elif delta < 0.0:
return (0,)
else:
return (1, (-b/(2*a)))
if __name__ == "__main__":
print(trinome(1.0, -3.0, 2.0))
print(trinome(1.0, -2.0, 1.0))
print(trinome(1.0, 1.0, 1.0))