Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is for my linux class and please use the awk command. Below are the student

ID: 3795626 • Letter: T

Question

This is for my linux class and please use the awk command.

Below are the student grades for each class component:

$ cat score

pchen72 50 71 55 93 115

jmaszk   45 76 49 88 102

bvbui    59 78 53 96 145

mtcrowle 33 65 39 82 100

mrchave3 54 77 56 98 158

Write a awk script called activity6.1-8.awk that compute the final percentage score for each student, as well as the class average

The max score is 450 and should be set in the BEGIN block

The output should be (round the score to nearest integer):

Total number of records: 5

Final score for pchen72 = 85.33%

Final score for jmaszk = 80%

Class Average = 86.1%

Explanation / Answer

data = []

with open('score.txt') as f:
for line in f:
split_line = [i for i in line.split() ]
data.append(split_line)

length = len(data)
class_percentage = 0
print " Final Score computation "
print "Total number of records:",length

for student in data:
score = student[1:] #take out all the score part
score = map(int, score) #to convert string into int
percentage = (sum(score)*100.0/450.0)
class_percentage += percentage
print "Final score for ",student[0]," = %.0f"%percentage,"%"

class_percentage /= length
print "Class Average = %.0f"%class_percentage,"% "

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote