In: Computer Science
Programming Project #6: Bowling Team
need to use python
Problem
Expected Duration: 3-4 hours
Prerequisites: None
Knowing that you are a budding programmer, your friends have
asked you to create a scoring program for your Saturday bowling
league. Your program should take a name, team number, and score for
each player, and should deal with any number of players, but have 3
people to a team.
Your program should ignore invalid inputs, and not crash. Your
program should print the following lists in columns:
Last, your program should write each of the lists and the
summary information
to a text file called game_results.txt in the same format it is
displayed on the screen.
Note: You have the option of using pandas Dataframes in your
program. Just make sure the console and file output
has the required structure and format.
#function to check alphabetical order
def isGreater(name1,name2):
length=0
if(len(name1)<len(name2)):
length=len(name1)
else:
length=len(name2)
for i in range(0,length):
if(ord(name1[i])>ord(name2[i])):
return True
elif (ord(name1[i])<ord(name2[i])):
return False
return False
def scoresData():
data=[]
while True:
player=input("Enter the Name and Score of a Player :: ")
if(player==''):
break
data.append(player.split());
print("----------------------------------")
print("\tEntered Order::\nPlayer Name \t Score")
print("----------------------------------")
for player in data:
print(player[0],"\t\t",player[1])
print()
for i in range(0,len(data)+1):
for j in range(0,len(data)-i-1):
if(isGreater(data[j][0],data[j+1][0])):
temp=data[j]
data[j]=data[j+1]
data[j+1]=temp
print("----------------------------------")
print("\tAplhabetical Order::\nPlayer Name \t Score")
print("----------------------------------")
for y in data:
print(y[0],"\t\t",y[1])
print()
for i in range(0,len(data)):
for j in range(0,len(data)-1):
if(int(data[j][1])<int(data[j+1][1])):
temp=data[j]
data[j]=data[j+1]
data[j+1]=temp
print("----------------------------------")
print("\tScore Order::\nPlayer Name \t Score")
print("----------------------------------")
tot=0
for x in data:
print(x[0],"\t\t",x[1])
tot=tot+int(x[1])
print()
print("Congratulations! Mr/Ms."+data[0][0]," You scored highest of ",data[0][1],".")
print("Oh! Mr/Ms."+data[-1][0]," Sorry to say that scored minimum of ",data[-1][1],".")
print("Average of scores \t:: ",int(tot/len(data)))
scoresData()
OUTPUT:::