try this:
print("Your Goals Against Average is:", "{0:.2f}".format(GAA))
Question
I'm trying to write a program in python 3.3 that will enable a ice hockey goaltender to be able to calculate his goals against average and save percentage. GAA usually appears in this format:
1.50
And Save Percentage is displayed in the following format:
0.927
With that in mind, here is my code so far:
Goals_Against = input("Enter Number of Goals Allowed: ")
Games_Played = input("Enter Number of Games Played: ")
Shots_Faced = input("Enter Number of Shots Faced: ")
Shots_Saved = input("Enter Number of Shots Saved: ")
def GoalsAgainstAverage():
GAA = (int(Goals_Against) / int(Games_Played))
print("Your Goals Against Average is:",GAA)
format(GAA, '.2f')
def main():
GoalsAgainstAverage()
main()
After I enter in, for example, 12 as the input for Goals_Against and 8 as the input for Games_Played, it always prints in the following format:
1.5
Why is it not displaying as 1.50?
Solution
try this:
print("Your Goals Against Average is:", "{0:.2f}".format(GAA))