I'm trying to format the follow program so that the results for 'average' are only displayed to 2 decimal places. I get that the '%.2f' %
code is used to do that, but I can't figure out how to integrate it into the final line of code producing an error.
Here is the program and I'm working on.
#the user has to enter three numbers for the program to average
#request the first number
answer1 = input('Please enter the first number: ')
answer1 = int(answer1)
#request the second number
answer2 = input('Please enter the second number: ')
answer2 = int(answer2)
#request the third number
answer3 = input('Please enter the third number: ')
answer3 = int(answer3)
final = answer1 + answer2 + answer3
final = int(final)
#print the average
print('The average of these numbers is ', final / 3)
It's the final line here that I can't figure out where to insert the '%.2f' %
to return the results for 2 decimal places.
Any help would be greatly appreciated.