Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Student ID,Question 1,Question 2,Question 3,Question 4,Question 5,Question 6 205842,7,1,8,9,4,16.5 280642,11,2,3,5,10,21 289179,7,5,4.5,5,7,23 264178,12,8,7.5,11.5,3,11 215754,13,1,6.5,13.5,2,13...

1 answer below »
Student ID,Question 1,Question 2,Question 3,Question 4,Question 5,Question 6
205842,7,1,8,9,4,16.5
280642,11,2,3,5,10,21
289179,7,5,4.5,5,7,23
264178,12,8,7.5,11.5,3,11
215754,13,1,6.5,13.5,2,13
219697,17,2,3,6.5,8,11
288204,7,0,6.5,5.5,7,24.5
285280,14,0,4.5,5,2,23.5
265518,11,3,9.5,7.5,5,12.5
266254,20,10,5.5,13.5,6,21.5
286523,7,4,6.5,3,4,22.5
267208,19,6,5.5,2.5,0,21.5
285888,14,10,5.5,12,6,13.5
264302,18,6,5.5,15,10,17.5
205180,18,3,6,8,5,19.5
299348,15,5,8,12.5,9,11.5
299342,7,8,8.5,7.5,9,22.5
206786,18,0,2,4.5,1,17.5
276254,13,1,9.5,7.5,9,17.5
292954,9,2,9.5,8.5,1,19.5
296067,8,5,6.5,13,6,23
241386,13,10,8.5,14.5,10,15.5
225309,14,2,9.5,10,10,11.5
214376,17,4,6,8,4,22
283567,18,1,6.5,3,0,12
279311,17,9,9,7.5,5,13.5
237422,17,8,7.5,3.5,9,22
288359,7,2,8,15,7,19.5
292921,14,2,7,14,10,11.5
285434,20,7,6,13.5,6,11
250254,20,0,6,2.5,2,12.5
239240,20,10,5,13.5,4,21.5
288513,7,10,8,14,10,13
228626,17,2,2.5,11,2,21
225091,16,10,2,10.5,10,14.5
207213,9,0,4,2.5,10,23.5
201425,16,4,9,3,10,12.5
276740,9,7,3,10.5,6,16.5
251585,13,9,7.5,11,3,19
297243,8,10,7.5,7.5,1,21.5
210327,9,2,1.5,13.5,3,19.5
211064,8,1,9,4.5,10,22.5
205252,7,4,1.5,5.5,4,12.5
282679,15,9,5.5,10.5,0,17.5
247622,11,8,8,10,1,24
291465,15,6,8.5,12.5,2,14.5
222342,18,3,4.5,15,1,21.5
295354,18,5,2,9.5,8,24.5
236971,17,1,8.5,7,6,11
236888,12,3,5,7,5,18

Student ID,Question 1,Question 2,Question 3,Question 4,Question 5,Question 6
205842,6.5,6.5,9.5,5.5,3.5,9.5
280642,8.5,9.5,3.5,9.5,4,9.5
289179,7,9.5,9,9.5,7,4
264178,9,3.5,5.5,5,5.5,4.5
215754,5.5,9.5,5,5,4,9.5
219697,5,7.5,8,4.5,9,3.5
288204,4,5.5,6.5,9.5,9,9
285280,9.5,6,9,4,5,9
265518,9.5,4.5,7.5,5.5,7,3.5
266254,7,8.5,8,3.5,3.5,8.5
286523,7.5,8.5,9,9.5,9.5,6
267208,3.5,9.5,5.5,8,7,4
285888,3.5,7,8.5,7,8.5,5.5
264302,6.5,7.5,3.5,6,5,9
205180,9.5,7.5,9.5,3.5,7.5,6
299348,9.5,6.5,7,5,7.5,7
299342,4,5,6,3.5,8,5
206786,5.5,5,4,7,9.5,7
276254,9,6.5,8.5,6,9,7.5
292954,9.5,6.5,6,7,4.5,8
296067,3.5,8.5,6,7.5,4.5,4
241386,9,5.5,4,7,6.5,5.5
225309,9,4,5.5,6.5,3.5,3.5
214376,3.5,4.5,4.5,5.5,7,7
283567,4.5,9,6,8.5,9.5,8.5
279311,8,4.5,8,5,8.5,6
237422,4,4.5,9.5,3.5,7.5,7.5
288359,7,6,8,7.5,5.5,8.5
292921,4.5,9.5,4.5,4,5,6
285434,4.5,7.5,4,5,6.5,3.5
250254,8,8,5.5,9,9,6
239240,9.5,6,6,4.5,8.5,8
288513,4,3.5,9,7,8,5
228626,8.5,9.5,6,5.5,3.5,4
225091,8,8,5,5,8.5,6
207213,6,8.5,5,8,8.5,5.5
201425,8.5,8,6,6,6.5,4
276740,7,9,7,4.5,9.5,4.5
251585,9.5,8,5.5,8,4,8.5
297243,7,8,6,3.5,9.5,8.5
210327,9.5,5,3.5,4,7,8
211064,6.5,6.5,9,6,6.5,9.5
205252,7,4,8,6,8,6.5
282679,7,3.5,4,8,7.5,9.5
247622,6,9,5.5,5,8.5,9.5
291465,8.5,8,9.5,6.5,8,8
222342,4,3.5,5.5,6.5,3.5,8
295354,4.5,4,5,9,4.5,8.5
236971,3.5,7.5,8.5,4.5,3.5,7
236981,1.5,6,9,5,4.5,7

Question,Max score
Question 1,10
Question 2,10
Question 3,10
Question 4,10
Question 5,10
Question 6,10

Question,Max score
Question 1,20
Question 2,10
Question 3,10
Question 4,15
Question 5,10
Question 6,25

Week 4 Assessment: Code
Task
The aim of this assessment is to familiarize yourself with the pandas DataFrameobject -
in particular manipulating a DataFrame object to display information that can be extracted
from a data set.
Included with the scaffold are two csv files (grades01.csv and grades02.csv) detailing
the raw marks of students taking a fictional examination; and two further csv files
(ru
ic01.csv and ru
ic02.csv) summarizing the maximum mark available for each of
the six questions. Your task is to write a small program that loads the data into Python
and displays some information about the data.
Task details
• Your program should begin by prompting the user to enter a csv file containing
the students' IDs and their raw mark for each of six questions, with the prompt
Enter grades file:
• Your program should then prompt the user to enter a csv file containing details of
the maximum mark available for each of the questions, with the prompt Enter
u
ic file:
• Your program should then prompt the user to select one of five options with the
menu:
1. Print question average (mean)
2. Print question average (quantiles)
3. Print student totals
4. Print student percentages
5. Print student ranking
Please enter your choice:
• If the user selects 1, the program should display, by printing a pandas DataFrame,
the mean score for each of the questions (see Sample interactions)
• If the user selects 2, the program should display, by printing a pandas DataFrame,
the 25%, 50%, and 75% quantiles for each of the questions (see Sample
interactions)
• If the user selects 3, the program should display, by printing a pandas DataFrame,
the sum of the scores for each Student ID (see Sample interactions)
• If the user selects 4, the program should display, by printing a pandas DataFrame,
the percentage grade each student obtained for each question. The percentage
grade is given by:
percentage_grade = 100 * raw_grade / max_score
where raw_grade is the mark given in the grades file, and max_score is given in the
u
ic file.
• If the user selects 5, the program should display, by printing a pandas DataFrame,
the Student IDs, a
anged by:
o Decreasing average percentage grade, and, if equal,
o Increasing Student ID
If all questions have the same maximum score (as in ru
ic01.csv) then sorting by average percentage
grade is the same as sorting by sum of scores.
• After printing the user selected option, the program should end
If printing out your DataFrame results in ellipses (...), [especially when testing] try using the to_string()
method, e.g.: print(df.to_string())
• You may assume that
o valid entries are always made
o the grades files and ru
ic files follow the same structure (i.e. six
questions, fifty students, data in floats rounded to 1 d.p.)
o the outputs from the built-in pandas functions do not need formatting
Practice coding questions have been set to assist building a solution to this assessment.
Sample interactions
Enter grades file: grades01.csv
Enter ru
ic file: ru
ic01.csv
1. Print question average (mean)
2. Print question average (quantiles)
3. Print student totals
4. Print student percentages
5. Print student ranking
Please enter your choice: 1
XXXXXXXXXXMean
Question XXXXXXXXXX
Question XXXXXXXXXX
Question XXXXXXXXXX
Question XXXXXXXXXX
Question XXXXXXXXXX
Question XXXXXXXXXX
Enter grades file: grades01.csv
Enter ru
ic file: ru
ic01.csv
1. Print question average (mean)
2. Print question average (quantiles)
3. Print student totals
4. Print student percentages
5. Print student ranking
Please enter your choice: 2
XXXXXXXXXX% Median 75%
Question XXXXXXXXXX.500
Question XXXXXXXXXX.375
Question XXXXXXXXXX.375
Question XXXXXXXXXX.375
Question XXXXXXXXXX.500
Question XXXXXXXXXX.500
Enter grades file: grades01.csv
Enter ru
ic file: ru
ic01.csv
1. Print question average (mean)
2. Print question average (quantiles)
3. Print student totals
4. Print student percentages
5. Print student ranking
Please enter your choice: 3
Student ID Total
XXXXXXXXXX0
XXXXXXXXXX5
XXXXXXXXXX0
XXXXXXXXXX0
4
Answered Same Day Jul 30, 2021

Solution

Yogesh answered on Jul 31 2021
126 Votes
import pandas as pd
def main():
    grades = input("Enter grades file: ")
    ru
ic = input("Enter ru
ic file: ")
    
    # catch exception for invalid files
    try:
        df_grades = pd.read_csv(grades)
        df_ru
ic = pd.read_csv(ru
ic)
        
        #print(df_grades.head())
        #print(df_ru
ic.head())
        
        print("1. Print question average (mean)")
        print("2. Print question average (quantiles")
        print("3. Print student totals")
        print("4. Print student percentages")
        print("5. Print student ranking")
        
        # validation for choice
        while True:
            choice = input("Please enter your choice: ")
            
            if choice in ["1", "2", "3", "4", "5"]:
                
eak
            else:
                print("Invalid Option, Please choose co
ect option...\n")
                continue
        
        # call respective function as per choice
        if choice == "1":
            que_mean(df_grades)
        if choice == "2":
            que_quantiles(df_grades)
        if choice == "3":
            stud_totals(df_grades)
        if choice == "4":
            result = stud_percentage(df_grades,...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here