#
#Author: Brent Donoven
#Gets players names, gets # of at bats and hits
#calculates hitting % and prints
#
#Example output and input
#
#
#Enter in player name: Brent
#Enter in player name: Bri
#Enter in player name: done
#Enter Brent number of at bats: 3
#nter Brent number of at hits: 0
#Enter Brent number of at bats: 4
#Enter Brent number of at hits: 0
#Enter Brent number of at bats: 1
#Enter Brent number of at hits: 0
#Enter Brent number of at bats: -1
#Enter Bri number of at bats: 3
#Enter Bri number of at hits: 3
#Enter Bri number of at bats: 2
#Enter Bri number of at hits: 2
#Enter Bri number of at bats: 2
#Enter Bri number of at hits: 1
#Enter Bri number of at bats: -1
#Brent : 0.0
#Bri : 0.8571428571428571
playerNames = []
name = ""
# reads players names from input until the user enters done
#stores names in the List playerNames
while(name != "done"):
name = input("Enter in player name: ")
if(name != "done"):
playerNames.append(name)
playerPercents = []# stores hitting percentage
for x in range(0,len(playerNames)):
bats=0
hits=0
batsList = []
hitsList = []
#reads in number of at bats and hits until player enters -1
while(bats != -1):
bats = int(input("Enter " + str(playerNames[x]) + " number of at bats: "))
if(bats != -1):
hits = int(input("Enter " + str(playerNames[x]) + " number of at hits: "))
batsList.append(bats)
hitsList.append(hits)
totalBats = 0
totalHits = 0
#adds up the total number of bats for current player in for loop
for y in range(0,len(batsList)):
totalBats = totalBats + batsList[y]
#totalBats += batsList[y]
#adds up the total number of hits for current player in for loop
for y in range(0,len(hitsList)):
totalHits = totalHits + hitsList[y]
#adds hitting percentage to playPercents list
playerPercents.append(totalHits/totalBats)
#prints each player name followed by their hitting percentage
for x in range(0,len(playerNames)):
print(playerNames[x], ": ", playerPercents[x])