0% found this document useful (0 votes)
1 views

Section 9.11 - ICS 104 Introduction to Programming Using Python and C Fall 24 zyBooks

The document outlines a lab assignment for ICS 104, focusing on calculating course grades using Python. Students are required to read student data from a tab-separated values (tsv) file, compute average scores, assign letter grades, and generate a report. The report must include individual student scores and overall averages formatted to two decimal places.

Uploaded by

AbdullahLwayme
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Section 9.11 - ICS 104 Introduction to Programming Using Python and C Fall 24 zyBooks

The document outlines a lab assignment for ICS 104, focusing on calculating course grades using Python. Students are required to read student data from a tab-separated values (tsv) file, compute average scores, assign letter grades, and generate a report. The report must include individual student scores and overall averages formatted to two decimal places.

Uploaded by

AbdullahLwayme
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

My library >

ICS 104: Introduction to Programming Using Python and C Fall 24 home


 >    ABDULLAH ALLWAIM
9.11: LAB: Course Grade
9.10 LAB: Sorting TV Shows (dictionaries and lists)

Students:


Section 9.11 is a part of 1 assignment: Includes: zyLab
Lab12-Files-and-Exceptions
11/25/2024, 11:59 PM +03

9.11 LAB: Course Grade

Instructor note:

Use the following algorithm:

Read the whole Ole using readlines()


create a list of 3 elements with 0's as initial values to contain the total of each exam
go over each element of the list
remove the \n character at the end
write the element to the output Ole
create a list of strings from that element using split()
convert the 3 scores to numbers either using list comprehension or for loop
Ond the average of the scores of one student and Ond his/her letter grade. You can make separate
function to receive the score and return letter grade
Add each exam to the total list using the corresponding index
Once outside the loop, Ond the average of each exam i.e. midterm1, midterm2 and Onal
write them to the output Ole
make sure to insert the '\n' at the right places

LAB
ACTIVITY 9.11.1: LAB: Course Grade   10 / 10

Write a program that reads the student information from a tab separated values (tsv) Ole. The program
then creates a text Ole that records the course grades of the students. Each row of the tsv Ole contains the
Last Name, First Name, Midterm1 score, Midterm2 score, and the Final score of a student. A sample of
the student information is provided in StudentInfo.tsv. Assume the number of students is at least 1 and at
most 20. Assume also the last names and Orst names do not contain whitespaces.

The program performs the following tasks:

Read the Ole name of the tsv Ole from the user.
Open the tsv Ole and read the student information.
Compute the average exam score of each student.
Assign a letter grade to each student based on the average exam score in the following scale:
A: 90 =< x
B: 80 =< x < 90
C: 70 =< x < 80
D: 60 =< x < 70
F: x < 60
Compute the average of each exam.
Output the last names, Orst names, exam scores, and letter grades of the students into a text Ole
named report.txt. Output one student per row and separate the values with a tab character.
Output the average of each exam, with two digits after the decimal point, at the end of report.txt.
Hint: Use the format speciOcation to set the precision of the output.

Ex: If the input of the program is:

StudentInfo.tsv
and the contents of StudentInfo.tsv are:

Barrett Edan 70 45 59
Bradshaw Reagan 96 97 88
Charlton Caius 73 94 80
Mayo Tyrese 88 61 36
Stern Brenda 90 86 45
the Ole report.txt should contain:

Barrett Edan 70 45 59 F
Bradshaw Reagan 96 97 88 A
Charlton Caius 73 94 80 B
Mayo Tyrese 88 61 36 D
Stern Brenda 90 86 45 C

Averages: midterm1 83.40, midterm2 76.60, final 61.60

4 Run  History Tutorial

main.py
20

21 file = open(fileName)
22 numoflines = file.readlines()
23 file.close()
24
25 report = open('report.txt', 'w')
26
27 for i in numoflines:
28 data = i.strip().split()
29
30 first= data[0]
31 last=data[1]
32 mid1=int(data[2])
33 mid2= int(data[3])
34 final=int(data[4])
35 mid1sum+= mid1
36 mid2sum +=mid2
37 finalsum += final
38 numofstudents +=1
39 grades= get_grade(mid1, mid2, final)
40 report.write(f'{first}\t{last}\t{mid1}\t{mid2}\t{final}\t{grades}\n')

DESKTOP CONSOLE

Submit for grading

Coding trail of your work What is this?

11/24 U - 0 ,0 ,0 ,10 - min:15

Latest submission - 12:23 PM +03 on Submission passed all Total score: 10 /


11/24/24 tests  10

Only show failing tests Open submission's code

1: Compare output 4/4

Compare output

Input StudentInfo.tsv

Your Output Expected output

1. Barrett Edan 70 45 59 1. FBarrett Edan 70 45 59 F

2. Bradshaw Reagan 96 97 2. 88
Bradshaw
A Reagan 96 97 88

3. Charlton Caius 73 94 3. 80
Charlton
B Caius 73 94 80

4. Mayo Tyrese 88 61 36 4. DMayo Tyrese 88 61 36 D

5. Stern Brenda 90 86 45 5. CStern Brenda 90 86 45 C

6. 6.
7. Averages: midterm1 83.40, midterm2 76.60,
7. Averages:
final 61.60
midterm1 83.40, midterm2 76.60, fi

8. 8.

2: Compare output 3/3

Compare output

Input StudentInfo1.tsv

Your Output Expected output

1. Barber Ryley 97 65 55 1. CBarber Ryley 97 65 55 C

2. Barrett Edan 98 63 53 2. CBarrett Edan 98 63 53 C

3. Bradshaw Reagan 89 55 3. 38
Bradshaw
D Reagan 89 55 38

4. Cabot Henry 94 97 85 4. ACabot Henry 94 97 85 A

5. Charlton Caius 41 73 5. 75
Charlton
D Caius 41 73 75

6. Flynn Jane 99 95 70 6. BFlynn Jane 99 95 70 B

7. Holder Guto 59 71 61 7. DHolder Guto 59 71 61 D

8. King Sonya 85 43 56 8. DKing Sonya 85 43 56 D

9. Mayo Tyrese 76 57 96 9. CMayo Tyrese 76 57 96 C

10. Min Johnny 46 43 67 10.FMin Johnny 46 43 67 F

11. Preston Mcauley 89 98 94 11.APreston Mcauley 89 98 94 A

12. Robison Lynda 96 90 55 12.BRobison Lynda 96 90 55 B

3: Compare output 3/3

Compare output

Input StudentInfo2.tsv

Your Output Expected output

1. Stott Peyton 80 57 75 1. CStott Peyton 80 57 75 C

2. 2.
3. Averages: midterm1 80.00, midterm2 57.00,
3. Averages:
final 75.00
midterm1 80.00, midterm2 57.00, fi

4. 4.

Previous submissions

10:41 AM on 11/24/24 0 / 10 View 


12:21 PM on 11/24/24 0 / 10 View 
12:22 PM on 11/24/24 0 / 10 View 

How was
this | Provide section feedback
section?

Activity summary for assignment: Lab12-Files-and-Exceptions 60 / 60 points


11/25/2024, 11:59 PM +03

Completion details 

9.12 LAB: File name change

You might also like