If I re-take a course that I failed and obtain a better grade which grade will appear on my official transcript and which grade will be used to calculate averages?

Grades for both course attempts appear on your official academic record and both will be used to calculate all averages.