Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python: Code to follow q5-grades.py: # Read from a file with student scores. # Each line has: # Course number, Student ID, Score (score

In Python:

image text in transcribed

Code to follow q5-grades.py:

# Read from a file with student scores. # Each line has: # Course number, Student ID, Score (score is an int, 0 through 100).

# Your goal: Compute each student's GPA. # Print, one per line: # Student ID, Total Points, GPA. # # Use this grading scale: # Score: 94 90 87 84 80 77 74 70 67 64 60

import sys

def main(): if len(sys.argv) != 2: print("Usage:") print(" python q5-grades.py ") sys.exit(1) file_name = sys.argv[1]

# 1. Read the file. # 2. For each line, # 3. get the student, and score # 4. convert score to grade points # 5. update student's total points # 6. For each student, # 7. get total points, and average points.

if __name__ == '__main__': main()

part of scores.csv:

CS414 dk2004 75
CS414 ih2094 68
CS414 mc2010 66
CS414 yq2053 78
CS414 le2069 68
CS414 qy2068 78
CS414 uh2074 96
CS417 uh2074 76
CS417 sx2001 80
CS417 mc2010 85
CS417 dk2004 82
CS417 le2069 73
CS417 rk2055 89
CS417 pq2037 70
CS415 le2069 78
CS415 uh2074 66
CS415 ih2094 79
CS415 yq2053 72
CS415 qy2068 83
CS415 sx2001 82
CS415 rk2055 89
CS415 pq2037 82
CS415 mc2010 80
CS415 dk2004 89
CS416 dk2004 75
CS416 sx2001 71
CS416 uh2074 76
CS416 qy2068 83
CS416 ih2094 63
CS416 le2069 72
CS416 mc2010 84
5. [50 points] Write a program q5-grades . py that expects a single command-line argument, which is a file name. The file name will not contain spaces. Each line in the file has three fields, separated by commas: - course name - student login - score (an int) Your program should open and read the file's contents, and compute each student's grade-point average. Output: print one line per student, with three values, separated by commas: - student login - student's total grade points - student's GPA Use this scale to convert a score into grade points

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions