Informatics Practices

Write a program that reads students marks from a ‘Result.csv’ file and displays percentage of each student.

Python Data Handling

2 Likes

Answer

import pandas as pd
df = pd.read_csv('Result.csv')
df['Total_marks'] = df[['Maths', 'Science', 'English',]].sum(axis=1)
df['Percentage'] = (df['Total_marks'] / 300) * 100
print("Percentage of each student: ")
print(df[['Name', 'Percentage']])

Output

Percentage of each student: 
    Name  Percentage
0  Rahul   85.000000
1  Rohan   81.666667
2   Riya   88.333333
3    Raj   86.666667

Answered By

2 Likes


Related Questions