This repository has been archived by the owner on Jan 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoyennemod.py
80 lines (64 loc) · 2.05 KB
/
moyennemod.py
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
#!/usr/bin/python3.8
#! -*- coding:Utf-8 -*
# moyenne
def moyenne(tmp, mid = False):
"""
Calcul de moyenne a partir d'une liste avec des tulpes avec en premier:\n
les notes puis les coefs ;\n
Exemple : a = [(note, moyenne)]
"""
tmpnotes = [tmpnote * tmpcoef for tmpnote, tmpcoef in tmp] # Extraction des notes fois les coefs
#print(tmpnotes) # Debug
for index, note in enumerate(tmpnotes): # Combination des notes
if index == 0:
notes = tmpnotes[0]
else:
notes += tmpnotes[index]
#print(notes) # Debug
# Coefficiants
tmpcoef = [tmpcoef for note, tmpcoef in tmp] # Extraction des coefs
#print(tmpcoef) # Debug
for index, coef in enumerate(tmpcoef): # Combination des coefs
if index == 0:
coefs = tmpcoef[0]
else:
coefs += tmpcoef[index]
#print(coefs) # Debug
# Affichage final
# notes et coefs dans un tulpe
if mid == True:
matiere = (notes, coefs)
return matiere
# moyenne deja calculée
else:
matiere = notes / coefs
matiere = round(matiere, 2)
return matiere
# emoji
def emoji(variable):
'''Retourne des emojis pour un spectre de notes'''
if variable <= 0:
like = "\U0001F480"
if variable > 0 and variable <= 10:
like = " \U0001F915"
if variable > 10 and variable <= 15:
like = "\U0001F914"
if variable > 15 and variable < 18:
like = "\U0001F920"
if variable >= 18:
like = "\U0001F973"
if variable == 20:
like = "\U0001F389 \U0001F48E"
return like
# Separe des tulpes en 2 listes
def separate(var, noteask = True):
'''Separe 2 tulpes en 2 listes :\n
les notes : noteask = True
les coefs : noteask = False'''
data = list()
for note, coef in var: # Retourne 2 chaines de cararctères pour un un tulpe
if noteask == True:
data.append(note)
else:
data.append(coef)
return data