-
Notifications
You must be signed in to change notification settings - Fork 0
/
lists-percentage.py
27 lines (25 loc) · 1.05 KB
/
lists-percentage.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
#!/usr/bin/env python3
#----------------------------------------------------------------------------
# Created By : Gabriel Fonseca
# Created Date: 22/09/2022
# File Name : 'lists-percentage.py'
# Version = '0.0'
# ---------------------------------------------------------------------------
""" Calculate lists percentage
Number of students: nullStudents (int)
Null votes: nullVotes (int)
Votes for each list [X, Z, K]: lists (list)
"""
# ---------------------------------------------------------------------------
def listPercentage(nullStudents: int, nullVotes: int):
if (nullStudents == None or nullVotes == None):
return "Data values missing!"
if (type(nullStudents) != int or type(nullVotes) != int):
return "Invalid data type!"
lists = [
int(input('Votes for list X: ')),
int(input('Votes for list Z: ')),
int(input('Votes for list K: ')),
]
for index in range(3):
print(f'Lista {"X" if index==0 else "Z" if index==1 else "K"}: {((lists[index] / (nullStudents - nullVotes)) * 100)}%')