Hard
Grades by Department
Give each student a grade with
pd.cut on cgpa: bins (0, 3.0] → C, (3.0, 3.5] → B, (3.5, 4.0] → A. Then make pd.crosstab(df['dept'], df['grade']). Print a header line dept A B C and one line per department (alphabetical) with the counts, showing every grade column even if it is empty.Input
Lines 'name dept cgpa credits', then END.
Output
Lines.
Sample 1
Input
Mim CSE 3.82 120 Rafi EEE 3.41 98 Sara CSE 3.95 132 Tuhin BBA 3.60 110 Nadia CSE 3.71 125 END
Output
dept A B C BBA 1 0 0 CSE 3 0 0 EEE 0 1 0
Sample 2
Input
A CSE 3.00 100 END
Output
dept A B C CSE 0 0 1
Output appears here