You are on page 1of 3

Data Science Final

Rohma irfan
F2021054085

# Importing and Displaying Data

import pandas as pd

# Import the student_grades.csv file into Python using Pandas

student_file = pd.read_csv ("/student.csv")

# displaying the first 5 rows

Student_ID Quiz1 Quiz2 Assignment FinalExam


0 1 8 7 16 40
1 2 6 9 18 45
2 3 9 8 15 38
3 4 7 6 14 42
4 5 5 8 17 48

Print (student.head())

# Data Manipulation

# Calculate the total score for each student

# Calculate the average score for each quiz and the assignment

quiz_columns = ['Quiz1', 'Quiz2']

student['QuizAverage'] = student[quiz_columns].mean(axis=1)

student['AssignmentAverage'] = student['Assignment']

# Data Visualization

# Plot a histogram showing the distribution of final exam scores

student['FinalExam'].plot(kind='hist', bins=10, title='Final Exam Scores Distribution')

# Plot a line graph showing the trend of Quiz1 scores across students

student.plot(x='StudentID', y='Quiz1', kind='line', title='Quiz1 Scores Across Students')

# Analysis
# Identify the student(s) with the highest total score

highest_score_student = student.loc[df['TotalScore'].idxmax()]

# Calculate the average total score for all students

average_total_score = df['TotalScore'].mean()

# Questions

# Variables

# A variable in programming is a symbolic name associated with a value.

example_variable = student['Quiz1']

# Arithmetic Operations

# Calculate the total score for the first student

first_student_total_score = student.loc[0, ['Quiz1', 'Quiz2', 'Assignment', 'FinalExam']].sum()

# Importing Data & Displaying Selected Rows

# Import the dataset and display the first 3 rows

student_head3 = pd.read_csv('student_grades.csv').head(3)

print(student_head3)

# If-Else Statements

# Create a condition based on total score

total_score = student.loc[0, 'TotalScore']

if total_score > 80:

print("Excellent!")

elif 60 <= total_score <= 80:

print("Good!")

else:

print("Work harder!")

# Lists & Subsets of Lists

# A list in Python is an ordered collection of elements.

quiz1_scores_list = df['Quiz1'].tolist()

# Defining a Function

# Define a function to calculate the average score


def calculate_average(scores):

return sum(scores) / len(scores)

You might also like