-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculate.py
32 lines (25 loc) · 942 Bytes
/
calculate.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
# Calculate the passer rating of a quarterback
# Python 3, but cover the option for 2.6+
from __future__ import print_function
# Manually change these numbers
# Note: These must be floats
completions = 22.0
attempts = 28.0
passingYards = 278.0
touchdowns = 4.0
interceptions = 0.0
# Do the calculation here:
# There are 5 parts
# Part 1: ((Completions / Attempts) - 0.3) * 5
part1 = ((completions / attempts) - 0.3) * 5
# Part 2: ((Passing Yards / Attempts) - 3) * 0.25
part2 = ((passingYards / attempts) - 3) * 0.25
# Part 3: (Touchdowns / Attempts) * 20
part3 = (touchdowns / attempts) * 20
# Part 4: 2.375 - ((Interceptions / Attempts) * 25)
part4 = 2.375 - ((interceptions / attempts) * 25)
# Part 5: Final Calculation
# ((Part1 + Part2 + Part3 + Part4) / 6) * 100
finalCalculation = ((part1 + part2 + part3 + part4) / 6) * 100
# Print the result to the user
print("The passer rating is: " + "{0:.2f}".format(finalCalculation))