Question

Please in Python: Studentlist.txt: 1237, Davis, Michael 1244, White, Ronald 2365, Smith, Jason 3458, Wilson, Robert...

Please in Python:

Studentlist.txt:

1237, Davis, Michael

1244, White, Ronald

2365, Smith, Jason

3458, Wilson, Robert

Gradebook.txt:

1237,1,87

1244,1,79

2365,1,86

2365,2,96

3458,1,88

3458,8,68

1237,2,84

1237,3,90

1244,4,96

1244,6,83

2365,3,73

2365,5,74

3458,7,70

3458,2,89

3458,3,77

2365,4,89

1237,4,78

1244,3,89

2365,6,86

3458,4,84

3458,5,93

1244,2,88

1237,5,86

2365,7,92

3458,6,67

1244,5,72

Modify the gradebook assignment that you created by combining the student records and

the grades into an array.

Calculate the average and grades from the info in the array.

Add the average and grade to the student record in the array.

After all the records have been processed and calculations are complete, print the array.

The complete program output is:

[['1237', 'Davis', 'Michael', '87', '84', '90', '78', '86', '85.0', 'B'], ['1244', 'White', 'Ronald',

'79', '96', '83', '89', '88', '72', '84.5', 'B'], ['2365', 'Smith', 'Jason', '86', '96', '73', '74', '89',

'86', '92', '85.14', 'B'], ['3458', 'Wilson', 'Robert', '88', '68', '70', '89', '77', '84', '93', '67',

'79.5', 'C']]

Do this program a section at a time.

Get the data from the student file and build the first part of the array (the student info)

Get the data from the grade file and append each of the scores to the correct student.

Compute the grade based on the scores. Will have to loop through using the length.

Add the computed average and grade to each student’s record.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// For any doubt, feel free to comment.

CODE with Comments:-

#List of Students
studentlist=[]

# Function to read student file
def read_students():
    f = open("Studentlist.txt", "r")
    for x in f:
        # Removing \n from end
        x = x.split("\n")
        x = x[0]
        # Splitting line by ,
        s = x.split(",")
        studentlist.append(s)
    f.close()

# Function to read Gradebook file
def read_gradebook():
    f = open("Gradebook.txt","r")
    for x in f:
        # Removing \n from end
        x = x.split("\n")
        x = x[0]
        # Splitting line by ,
        x = x.split(",")
        # Checking for student ID
        for j in studentlist:
            if j[0] == x[0]:
                j.append(x[2])

# Function to append average
def append_average():
    for x in studentlist:
        cnt=0
        sum=0
        # Calculating sum for all its marks
        for i in range(3,len(x)):
            cnt+=1
            sum=sum+(int(x[i]))
        aver = sum/cnt
        # Rounding average up to 2 decimal places
        aver = int(aver*100)
        aver = aver/100
        # Appending average
        x.append(str(aver))

# Function to append Grade
def append_grade():
    for x in studentlist:
        # Accessing the average
        aver = float(x[len(x)-1])
        # Deciding grade according to average
        if aver > 90 :
            x.append("A")
        elif aver > 80 :
            x.append("B")
        elif aver > 70 :
            x.append("C")


read_students()
read_gradebook()
append_average()
append_grade()
print(studentlist)
print()

for x in studentlist:
    print(x)

Code Snippets:-

Output:-

Add a comment
Know the answer?
Add Answer to:
Please in Python: Studentlist.txt: 1237, Davis, Michael 1244, White, Ronald 2365, Smith, Jason 3458, Wilson, Robert...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++: Create a grade book program that includes a class of up to 20 students each...

    C++: Create a grade book program that includes a class of up to 20 students each with 5 test grades (4 tests plus a Final). The sample gradebook input file (CSCI1306.txt) is attached. The students’ grades should be kept in an array. Once all students and their test scores are read in, calculate each student’s average (4 tests plus Final counts double) and letter grade for the class. The output of this program is a tabular grade report that is...

  • Write a program to calculate students’ average test scores and their grades. You may assume the...

    Write a program to calculate students’ average test scores and their grades. You may assume the following data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three...

  • Write a program to calculate students’ average test scores and their grades. You may assume the...

    Write a program to calculate students’ average test scores and their grades. You may assume the following data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three...

  • Please help me with this program.You are to write a C++ program that will read in...

    Please help me with this program.You are to write a C++ program that will read in up to 15 students with student information and grades. Your program will compute an average and print out certain reports. Format: The information for each student is on separate lines of input. The first data will be the student�s ID number, next line is the students name, next the students classification, and the last line are the 10 grades where the last grade is...

  • using java Program: Please read the complete prompt before going into coding. Write a program that...

    using java Program: Please read the complete prompt before going into coding. Write a program that handles the gradebook for the instructor. You must use a 2D array when storing the gradebook. The student ID as well as all grades should be of type int. To make the test process easy, generate the grade with random numbers. For this purpose, create a method that asks the user to enter how many students there are in the classroom. Then, in each...

  • Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate...

    Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate the number of test scores the user enters; have scores fall into a normal distribution for grades -Display all of the generated scores - no more than 10 per line -Calculate and display the average of all scores -Find and display the number of scores above the overall average (previous output) -Find and display the letter grade that corresponds to the average above (overall...

  • Please program in C++ and document the code as you go so I can understand what...

    Please program in C++ and document the code as you go so I can understand what you did for example ///This code does~ Your help is super appreciated. Ill make sure to like and review to however the best answer needs. Overview You will revisit the program that you wrote for Assignment 2 and add functionality that you developed in Assignment 3. Some additional functionality will be added to better the reporting of the students’ scores. There will be 11...

  • The Computer Science Instructor has just completed compiling all the grades for the C++ Programming class....

    The Computer Science Instructor has just completed compiling all the grades for the C++ Programming class. The grades were downloaded into a file titled ‘studentGrades.txt’ (attached). Write a C++ Program that reads this file and calculates the following as described : The final semester numeric and letter grade (using 10 point scale) Calculated as follows: Labs 1-6 (worth 50% of final grade) Lab 7 is extra credit (worth 2 % of final grade OR replaces lowest lab grade – Select...

  • For the following task, I have written code in C and need help in determining the...

    For the following task, I have written code in C and need help in determining the cause(s) of a segmentation fault which occurs when run. **It prints the message on line 47 "printf("Reading the input file and writing data to output file simultaneously..."); then results in a segmentation fault (core dumped) I am using mobaXterm v11.0 (GNU nano 2.0.9) CSV (comma-separated values) is a popular file format to store tabular kind of data. Each record is in a separate line...

  • Write a program that reads in BabyNames.txt and produces two files, boynames.txt and girlnames.txt, separating the...

    Write a program that reads in BabyNames.txt and produces two files, boynames.txt and girlnames.txt, separating the data for the boys and the girls, and listing them in alphabetical order. This is the code I have, Its not sorting the boys/girls names in seperate files. It is creatinf two files, but has all the names. I also need to alphabetize the names. with an Array. sort import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Scanner; public class BabyNames{ public static void main(String[]...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT