-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgrading_in_tables.py
More file actions
executable file
·47 lines (38 loc) · 1.13 KB
/
Copy pathgrading_in_tables.py
File metadata and controls
executable file
·47 lines (38 loc) · 1.13 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
#!/usr/bin/env python3
# Naz-Al Islam
# 04/30/16
# Printing grades points by names in a table
grades = [
("Tyler", [100, 95, 90, 92, 100, 100]),
("Timmy", [100, 50, 55, 0, 35, 85]),
("Tammy", [100, 100, 100, 95, 98, 92]),
("Tanya", [100, 100, 100, 100, 92, 90]),
("Tony", [90, 90, 90, 92, 85, 100])]
def getLetter(num):
""" This function takes the number grade as a variable and will return
the letter (as a string) that this number grade equates to
"""
if num < 65:
return 'F'
elif num < 75:
return 'D'
elif num < 85:
return 'C'
elif num < 95:
return 'B'
else:
return 'A'
def main():
""" This main function will print each student's name and average grade,
and will also call the getLetter function to also print the letter
grade that equates to the number grade of the average...
"""
s = 0
for i in numbers:
s = s + i
r = round(s / len(numbers), 2)
return r
for (name, numbers) in grades:
print(name, '\t', main(), '\t', getLetter(main()))
if __name__ == "__main__":
main()