-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfonction_wdgets.py
More file actions
250 lines (218 loc) · 5.79 KB
/
fonction_wdgets.py
File metadata and controls
250 lines (218 loc) · 5.79 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
import fonction_math
import math
type_de_calcul = "inconnu"
curs = 0
index_tab = 0
tab = [0]*100
tab_nombre_complet = [0]*100
k = 0
def zero():
global curs
global index_tab
curs = 0
tab[index_tab] = curs
index_tab += 1
print(curs)
def un():
global curs
global index_tab
curs = 1
tab[index_tab] = curs
index_tab += 1
print(curs)
def deux():
global curs
global index_tab
curs = 2
tab[index_tab] = curs
index_tab += 1
print(curs)
def trois():
global curs
global index_tab
curs = 3
tab[index_tab] = curs
index_tab += 1
print(curs)
def quatre():
global curs
global index_tab
curs = 4
tab[index_tab] = curs
index_tab += 1
print(curs)
def cinq():
global curs
global index_tab
curs = 5
tab[index_tab] = curs
index_tab += 1
print(curs)
def six():
global curs
global index_tab
curs = 6
tab[index_tab] = curs
index_tab += 1
print(curs)
def sept():
global curs
global index_tab
curs = 7
tab[index_tab] = curs
index_tab += 1
print(curs)
def huit():
global curs
global index_tab
curs = 8
tab[index_tab] = curs
index_tab += 1
print(curs)
def neuf():
global curs
global index_tab
curs = 9
tab[index_tab] = curs
index_tab += 1
print(curs)
def plus():
global type_de_calcul
type_de_calcul = "+"
remplir_tableau_nombre_complet()
print("plus")
def moins():
global type_de_calcul
type_de_calcul = "-"
remplir_tableau_nombre_complet()
print("moins")
def mul():
global type_de_calcul
type_de_calcul = "x"
remplir_tableau_nombre_complet()
print("fois")
def div():
global type_de_calcul
type_de_calcul = "/"
remplir_tableau_nombre_complet()
print("diviser par ")
def sinus():
global type_de_calcul
type_de_calcul = "sin"
print("sinus")
def cosinus():
global type_de_calcul
type_de_calcul = "cos"
print("cosinus")
def tangente():
global type_de_calcul
type_de_calcul = "tan"
print("tangente")
def cotangente():
global type_de_calcul
type_de_calcul = "cotan"
print("cotangente")
def logarithme():
global type_de_calcul
type_de_calcul = "log"
print("logarithme")
def logarithme_neperien():
global type_de_calcul
type_de_calcul = "ln"
print("logarithme_neperien")
def exponentielle():
global type_de_calcul
type_de_calcul = "exp"
print("exponentielle")
def puissance():
global type_de_calcul
type_de_calcul = "puis"
print("puissance")
def remplir_tableau_nombre_complet():
global tab_nombre_complet
global k
tab_nombre_complet[k] = recuperer_nombre()
k += 1
#fonction qui convetis une liste de nombre en un nombre complet
#Ex : (3,2,4) -> 324
def recuperer_nombre():
j = 0
global index_tab
nbr_complet = 0
index_tab_copy = index_tab
while(j<index_tab):
nbr_complet += math.pow(10,(index_tab_copy - 1))*tab[j]
j += 1
index_tab_copy -= 1
index_tab = 0
return nbr_complet
def egal():
global k
remplir_tableau_nombre_complet()
t = 0
resultat = 0
if (type_de_calcul == "x"):
resultat = 1
# fonctions (+ , - , x , /) prenant plusieurs arguments
while(t < k):
print(tab_nombre_complet[t])
if (type_de_calcul == "+"):
if (t == 1):
resultat += fonction_math.addition(tab_nombre_complet[t-1],tab_nombre_complet[t])
elif(t > 1):
resultat = fonction_math.addition(resultat,tab_nombre_complet[t])
elif(type_de_calcul == "-"):
if (t == 1):
resultat += fonction_math.soustraction(tab_nombre_complet[t-1],tab_nombre_complet[t])
elif(t > 1):
resultat = fonction_math.soustraction(resultat,tab_nombre_complet[t])
elif(type_de_calcul == "x"):
if (t == 1):
resultat = fonction_math.multipliactionn(tab_nombre_complet[t-1],tab_nombre_complet[t])
elif(t > 1):
resultat = fonction_math.multipliactionn(resultat,tab_nombre_complet[t])
elif(type_de_calcul == "/"):
if (t == 1):
resultat = fonction_math.division(tab_nombre_complet[t-1],tab_nombre_complet[t])
elif(t > 1):
resultat = fonction_math.division(resultat,tab_nombre_complet[t])
else:
break
t += 1
#fonctions à un seule paramètre
if (type_de_calcul == "sin"):
resultat = fonction_math.sinus(tab_nombre_complet[0])
elif (type_de_calcul == "cos"):
resultat = fonction_math.cosinus(tab_nombre_complet[0])
elif (type_de_calcul == "tan"):
resultat = fonction_math.tangente(tab_nombre_complet[0])
elif (type_de_calcul == "cotan"):
resultat = fonction_math.cotangente(tab_nombre_complet[0])
elif (type_de_calcul == "log"):
resultat = fonction_math.logarithme(tab_nombre_complet[0])
elif (type_de_calcul == "ln"):
resultat = fonction_math.logarithme_neperien(tab_nombre_complet[0])
elif (type_de_calcul == "exp"):
resultat = fonction_math.exponentielle(tab_nombre_complet[0])
elif (type_de_calcul == "puis"):
resultat = fonction_math.puissance_de_dix(tab_nombre_complet[0])
print(f"le resultat du calcul est : {resultat}")
# remet à zero tout les paramètre ainsi que la liste
p = 0
while(p < len(tab_nombre_complet)):
tab_nombre_complet[p] = 0
p += 1
k = 0
t = 0
#retourne le resulat
return resultat
# efface toout en remettant à jour les listes et les curseurs de positions
def clear():
global k
global t
p = 0
while(p < len(tab_nombre_complet)):
tab_nombre_complet[p] = 0
p += 1
k = 0
t = 0