Question

Task description:

NOTE: - MUST BE ANSWERED IN PYTHON CODE FORMAT, USING PANDAS & DISPLAY A SCREEN SHOT OF THE UPDATED OUTPUT FROM YOUR CODE.

Please comment out code with description.

You are given a student result data file (result_withoutTotal.csv).

It has columns: ID: student id

Ass1 ~ Ass4: assignment scores (out of 100); weight of ass1, ass2, ass3 and ass4 is 5%, 15%, 5%, and 15%, respectively.

Exam: examination score (out of 120); weight is 60%.

Total score can be calculated using formula:

Total = 5%*(ass1+ass3) + 15%*(ass2+ass4) + 60%*exam

Read students’ result data from file result_withoutTotal.csv - (https://www.dropbox.com/s/w9r0yddyd79bh4n/result_withoutTotal.csv?dl=0)

add:

Total column: Total = 5%*(ass1+ass3) + 15%*(ass2+ass4) + 60%*exam.

The max Total score is 100. Reduce the Total to 100 if the calculated Total >100.

Final column: Final = Total score rounded to the nearest integer.

To pass the unit, a student must achieve at least 50 of the Total and 40% of Exam which is 48 out of 120 (or Total >= 50 and Exam >= 48).

If a student failed the hurdle (Exam >= 48), the max Final is 44. No change to Final score if Final <44.

Grade column: N (Final <=49.45), P (49.45 < Final <=59.45), C (59.45 < Final <=69.45), D (69.45 < Final <=79.45) and HD (79.45 < Final).

Display the following:

1. The result data file with the 3 new columns

2. The students with exam score < 48

3. The students with exam score > 100

////////////////////////////////////////////////////

NOTE: - MUST BE ANSWERED IN PYTHON CODE FORMAT, USING PANDAS & DISPLAY A SCREEN SHOT OF THE UPDATED OUTPUT.

Please comment out code with description.

Sample output​​​​:

students with exam score < 48 Ass1 Ass2 Ass3 Ass4 Exam Total Final Grade ID 44 44 3 74.3 54.4 63.0 63. 9 89.8 81.3 82.0 90.4

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

Here is the code you asked for.

# importing pandas as pd
import pandas as pd
df_csv = pd.read_csv('result_withoutTotal.csv')
tot=list()
fin=list()
grad=list()
#iterating through the each row in a dataframe
for row in df_csv.iterrows():
    #making it as list to more clear about indexes like we will series data at first index with all the attribute names like Ass1 and Ass2 ,Ass3 and Exams so we can access value with index and name of attribute
    a=list(row)
    #here a[1].Ass1 means accessing ass1 value from dataframe which is in first index of list
    total=((5/100)*(a[1].Ass1+a[1].Ass3))+ ((15/100)*(a[1].Ass2+a[1].Ass4))+((60/100)*a[1].Exam)
    if(total>100):
        total=100
    #finding the final
    if(total>=50 and a[1].Exam>=48):
        final=round(total)
    elif(total<=50 and a[1].Exam<=48):
        final=round(total)
    else:
        final=44
    #finding the grade
    if(final<=49.45):
        grade='N'
    elif(final>49.45 and final<=59.45):
        grade='P'
    elif(final>59.45 and final<=69.45):
        grade='C'
    elif(final>69.45 and final<=79.45):
        grade='D'
    else:
        grade='HD'
    #appending all the values to respective lists
    tot.append(total)
    fin.append(final)
    grad.append(grade)
df_csv['Total']=tot
df_csv['Final']=fin
df_csv['Grade']=grad
#we are making id as a index here
df_csv.set_index(['ID'], inplace = True)
#writing dataframe to csv
df_csv.to_csv('result_withoutTotal.csv', header=True, index=True)
df_res = df_csv[df_csv['Final'] < 48]
print("Students with marks < 48")
print(df_res)
print("Students with marks > 100")
df_res = df_csv[df_csv['Final'] >=100]
print(df_res)

ouputs:

N Students with marks < 48 Assl Ass Ass Ass4 Exam Total Final Grade ID 3 74.3 54.4 63.0 63.9 31 43.210 43.0 89.8 81.3 82.0 90

csv before:

59 A B C D E F D Ass1 Ass2 Ass3 Ass4 Exam 1 89.1 50 85 88.9 65 2 95.1 82.5 90.5 94.5 52 3 74.3 54.4 63 63.9 31 4 89.8 81.3 82

csv after:

HAWN 7 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 A B C D E F G H D Ass1 Ass2 Ass3 Ass4 Exam Total Final

Hope you like it,if you have any doubts let me know in comments, thank you

Add a comment
Know the answer?
Add Answer to:
Task description: NOTE: - MUST BE ANSWERED IN PYTHON CODE FORMAT, USING PANDAS & DISPLAY A...
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
  • Task description You are given a student result data file (result.csv). It has columns ID: studen...

    Please include screenshot of coding and program running - Python. Thanks in advance!! Task description You are given a student result data file (result.csv). It has columns ID: student id Assi ~ Ass4: assignment scores (out of 100); weight of assi, ass2, ass and ass4 is 5%, 15%, 5%, and 15%, respectively Exam: examination score (out of 120); weight is 60%. Hurdle is 40% of exam total (48) Total: weighted total result (5%" (ass1+ass3) + 15%" (ass2+ass4) + 60%"exam) ID...

  • Hi - Some help create a short program that uses a pandas DataFrame (solution MUST use...

    Hi - Some help create a short program that uses a pandas DataFrame (solution MUST use a DataFrame) to do the following. Please include comments /notes to explain what is going on. Solution does not need to define functions two csv files are included (grades01.csv): raw marks of students taking an examination; and a further csv file (rubric01.csv) summarizing the maximum mark available for each of the six questions. Structure of grades01: Student ID,Question 1,Question 2,Question 3,Question 4,Question 5,Question 6...

  • c++ implement a student class Determine the final scores, letter grades, and rankings of all students...

    c++ implement a student class Determine the final scores, letter grades, and rankings of all students in a course. All records of the course will be stored in an input file, and a record of each student will include the first name, id, five quiz scores, two exam scores, and one final exam score. For this project, you will develop a program named cpp to determine the final scores, letter grades, and rankings of all students in a course. All...

  • Logic and Decision Making ALL questions below must be answered. Show ALL step-by-step calculation...

    Logic and Decision Making ALL questions below must be answered. Show ALL step-by-step calculations, round all your final answers correctly, and include the units of measurement. Upload this modified Answer Form to the intellipath Unit 6 Submission lesson. Make sure that you submit your work in a modified MS Word document; handwritten work will not be accepted. If you need assistance, please contact your course instructor. A proposed directed study MATH125 class comprising 25 students earned the following grades on...

  • I am having trouble with my Python code in this dictionary and pickle program. Here is...

    I am having trouble with my Python code in this dictionary and pickle program. Here is my code but it is not running as i am receiving synthax error on the second line. class Student: def__init__(self,id,name,midterm,final): self.id=id self.name=name self.midterm=midterm self.final=final def calculate_grade(self): self.avg=(self.midterm+self.final)/2 if self.avg>=60 and self.avg<=80: self.g='A' elif self.avg>80 and self.avg<=100: self.g='A+' elif self.avg<60 and self.avg>=40: self.g='B' else: self.g='C' def getdata(self): return self.id,self.name.self.midterm,self.final,self.g CIT101 = {} CIT101["123"] = Student("123", "smith, john", 78, 86) CIT101["124"] = Student("124", "tom, alter", 50,...

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

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

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

  • Need code written for a java eclipse program that will follow the skeleton code. Exams and...

    Need code written for a java eclipse program that will follow the skeleton code. Exams and assignments are weighted You will design a Java grade calculator for this assignment. A user should be able to calculate her/his letter grade in COMS/MIS 207 by inputting their scores obtained on worksheets, assignments and exams into the program. A skeleton code named GradeCompute.java containing the main method and stubs for a few other methods, is provided to you. You must not modify/make changes...

  • Principles of Computer Science

    Question First, you need to design, code in Java, test and document a base class, Student. The Student class will have the following information, and all of these should be defined as Private: A. Title of the student (eg Mr, Miss, Ms, Mrs etc) B. A first name (given name) C. A last name (family name/surname) D. Student number (ID) – an integer number (of type long) E. A date of birth (in day/month/year format – three ints) - (Do NOT use the Date class from...

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