#!/usr/bin/env python3; ############################################################################### # This program computes NFL passer ratings. # # Copyright © 2020 Richard Lesh. All rights reserved. ############################################################################### import Utils # Begin Main try : input_str = Utils.prompt("Number of attempts: ") attempts = int(input_str) input_str = Utils.prompt("Number of completions: ") completions = int(input_str) input_str = Utils.prompt("Number of touchdown passes: ") touchdown_passes = int(input_str) input_str = Utils.prompt("Number of interceptions: ") interceptions = int(input_str) input_str = Utils.prompt("Number of passing yards: ") passing_yards = int(input_str) input_str = Utils.prompt("1 for NFL or 2 for NCAA: ") which = int(input_str) if (which == 1) : a = (completions / attempts - 0.3) * 5. b = (passing_yards / attempts - 3.) * 0.25 c = touchdown_passes / attempts * 20. d = 2.375 - (interceptions / attempts * 25.) RATING = (a + b + c + d) / 6. * 100. print("NFL Passer rating: {0:.1f}".format(RATING)) else : a = 8.4 * passing_yards b = 330. * touchdown_passes c = 100. * completions d = 200. * interceptions RATING = (a + b + c - d) / attempts print("NCAA Passer rating: {0:.1f}".format(RATING)) except ValueError as ex : print("Bad input! " + str(ex)) except Exception as ex : print("Don't know what went wrong!")