Question

Problem 3 (lab4_p3.py) An older, existing campus system has been previously storing student grades in list form with the foll

all should be solved using the basic data types, assignments, math operations, conditionals, loops, string functions, user defined functions, lists, tuples, file input/output and dictionaries.

Please use python

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

Code snippet with output below :
The below program takes nested list and converts it to nested dictionaries...
Program assumes this format as given in the question -> student name - ID - mid term - final
Uses len to determine number of lists inside grades_list and loop until that number. In case here it's 4 so loop will run from [0-3].
Checks if student name exists in dictionary inside the loop. If it doesn't then adds the new values to dictionary.

#         Python 3         #

grades_list = [["Emily Kaldwin", "ek12345", 88, 90], ["Sakura Kinomoto","sk12345", 98, 98],
        ["Maximilien Robespierre","mr12345", 76, 89], ["Emily Kaldwin", "ek12345", 100, 100]]

# order of List
# Name - NetID - Mid__term Grade - Final Grade

def convert_grades_list_to_dictionary(grad_list):
    # temp dict
    converted_dict = {}

    # Counts the grad_list and loop until that count
    for x in range(len(grad_list)):
        # Checks if entry exits in dict
        # if not add to the dict
        if not grad_list[x][0] in converted_dict:
            converted_dict[grad_list[x][0]] = { 'NetID' : grad_list[x][1], 'Mid__term Grade' : grad_list[x][2], 'Final Grade' : grad_list[x][3]}
    return converted_dict

grades_dictionary = convert_grades_list_to_dictionary(grades_list)

# From the question

print(grades_dictionary["Sakura Kinomoto"]["NetID"]) # should print "sk12345"
print(grades_dictionary["Emily Kaldwin"]["Mid__term Grade"]) #should print "88"
print(grades_dictionary["Maximilien Robespierre"]["Final Grade"]) #should print "89"

# For Testing purpose   #

print ("\n\nList: \n",grades_list)
print ("\n\nDictionary: \n",grades_dictionary)

# Program Ends #

Add a comment
Know the answer?
Add Answer to:
all should be solved using the basic data types, assignments, math operations, conditionals, loops, string functions,...
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
  • Many classes calculate a final grade by using a weighted scoring system. For example, “Assignments” might...

    Many classes calculate a final grade by using a weighted scoring system. For example, “Assignments” might be worth 40% of your final grade. To calculate the grade for the Assignments category, the teacher takes the percentage earned on the assignments and multiplies it by the weight. So if the student earned a 90% total on the Assignments, the teacher would take 90% x 40, which means the student earned a 36 percent on the Assignments section. The teacher then calculates...

  • have to create five different functions above and call it in the main fucntion. Project Exam...

    have to create five different functions above and call it in the main fucntion. Project Exam Statistics A CIS 22A class has two midterm exams with a score between 0 and 100 each. Fractional scores, such as 88.3 are not allowed. The students' ids and midterm exam scores are stored in a text file as shown below // id exam1 exam2 DH232 89 92 Write a program that reads data from an input file named exams.txt, calculates the average of...

  • public class StudentADT { //1. A Student class should include data attributes including a // student’s...

    public class StudentADT { //1. A Student class should include data attributes including a // student’s name (first, and last), a student number, //an array of 3 assignment grades, and an exam grade. private String firstName; private String lastName; private int studentNumber; private double[] assignmentGrades; private double examGrade; //the constructor StudentADT(firstNm, lastNm, stNo, asn1Grade, asn2Grade, asn3Grade, examGrade) public StudentADT(String firstNm, String lastNm, int stNo, double asn1Grade, double asn2Grade, double asn3Grade, double examGrade) { firstName = firstNm; lastName = lastNm; studentNumber...

  • 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...

  • PYTHON 3 Object Oriented Programming ***a9q3.py file below*** class GradeItem(object): # A Grade Item is anything...

    PYTHON 3 Object Oriented Programming ***a9q3.py file below*** class GradeItem(object): # A Grade Item is anything a course uses in a grading scheme, # like a test or an assignment. It has a score, which is assessed by # an instructor, and a maximum value, set by the instructor, and a weight, # which defines how much the item counts towards a final grade. def __init__(self, weight, scored=None, out_of=None): """ Purpose: Initialize the GradeItem object. Preconditions: :param weight: the weight...

  • Using C programming For this project, you have been tasked to read a text file with student grade...

    Using C programming For this project, you have been tasked to read a text file with student grades and perform several operations with them. First, you must read the file, loading the student records. Each record (line) contains the student’s identification number and then four of the student’s numerical test grades. Your application should find the average of the four grades and insert them into the same array as the id number and four grades. I suggest using a 5th...

  • python 3 question Project Description Electronic gradebooks are used by instructors to store grades on individual assignments and to calculate students’ overall grades. Perhaps your instructor uses gr...

    python 3 question Project Description Electronic gradebooks are used by instructors to store grades on individual assignments and to calculate students’ overall grades. Perhaps your instructor uses gradebook software to keep track of your grades. Some instructors like to calculate grades based on what is sometimes called a “total points” system. This is the simplest way to calculate grades. A student’s grade is the sum of the points earned on all assignments divided by the sum of the points available...

  • 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...

  • Lab Exercise #15 Assignment Overview This lab exercise provides practice with Pandas data analysis library. Data...

    Lab Exercise #15 Assignment Overview This lab exercise provides practice with Pandas data analysis library. Data Files We provide three comma-separated-value file, scores.csv , college_scorecard.csv, and mpg.csv. The first file is list of a few students and their exam grades. The second file includes data from 1996 through 2016 for all undergraduate degree-granting institutions of higher education. The data about the institution will help the students to make decision about the institution for their higher education such as student completion,...

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