You have been tasked to write a function that finds APFT failures for your compa
ID: 3590321 • Letter: Y
Question
You have been tasked to write a function that finds APFT failures for your company. The CO would like your function to read event scores from a file, compute each cadet's total score, determine whether the cadet received a PASS or FAIL, and write the email address and total score for failing cadets to a new file.
Write a function named pt_failures which takes two string parameters: the name of the input file and the name of the output file. For each of the cadets in your input file, calculate their score and determine if they earned a PASS or a FAIL. If the cadet failed, write the cadet's xnumber email address (x00000@usma.edu) and total score as a comma separated line in the output file. There should only be one cadet per line in the output file. apft_raw_scores.txt and apft_failures_expected.txt are provided for testing (in hw3_files.zip).
NOTE: A score of below 60 in any event earns a FAIL
Explanation / Answer
ef pt_failures(input,output):
file = open(input,"r")
file1 = open(output,"w")
for line in file:
list = line.split(',')
for j in range(len(list)):
if j > 0:
if int(list[j]) < 60:
fail = 1
file1.write(list[0] + "@usma.edu" + " " + str(int(list[1]) + int(list[2]) + int(list[3])) + " ")
break
pt_failures("apft_raw_score.txt","failures.txt")
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.