-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculadora-procentaje.py
35 lines (29 loc) · 1.05 KB
/
calculadora-procentaje.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
def calcular_porcentaje(dataBase, classification):
hits = 0
actualField = 0
actualRealClasification = []
for i in range(len(dataBase)):
if actualField == 0:
actualField = 1
elif actualField == 1:
actualField = 2
elif actualField == 2:
actualRealClasification.append(dataBase[i])
actualField = 0
for i in range(len(classification) - 2):
if actualRealClasification[i][0].lower() == classification[i].lower():
hits += 1
print("Porcentaje de aciertos: " + str(hits / len(classification) * 100) + "%")
def main():
dataBaseFile = input("Enter the name of the file with the real classification: ")
classificationFile = input("Enter the name of the file with the classification: ")
with open(dataBaseFile, "r") as file:
dataBase = file.read()
with open(classificationFile, "r") as file:
classification = file.read()
dataBase = dataBase.split(";")
dataBase = dataBase[3:]
classification = classification.split("\n")
calcular_porcentaje(dataBase, classification)
if __name__ == "__main__":
main()