-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwam.py
More file actions
executable file
·29 lines (21 loc) · 747 Bytes
/
wam.py
File metadata and controls
executable file
·29 lines (21 loc) · 747 Bytes
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
#!/usr/bin/env python3
# UNSW WAM --> sum of (grade * no. units) / total units
#Format:
import sys
import math
total_units = 0
linecount = 0 # not needed, but im releasing all my anger at the world into my code
total_grade = 0
for line in sys.stdin:
total_units += int(line.split()[1])
total_grade += float(line.split()[0]) * float(line.split()[1])
linecount += 1
if linecount == 0:
print("Nothing inputted. Don't waste my time.")
sys.exit(0)
if linecount == 1:
print("You are stupid and your wam is the only grade you've received thus far")
sys.exit(0)
# TODO: error checking + testing files
print(f" You current WAM is {total_grade} divide by {total_units}")
print(format(total_grade / total_units, '.3f'))