


























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



























1.Create a Bar Chart to compare the marks of 10 students in five different subjects. Input:- import pandas as pd import matplotlib.pyplot as plt import numpy as np
np.random.seed(42) data = np.random.randint(40, 100, size=(10, 5)) students = [f'Student {i+1}' for i in range(10)] subjects = ['Math', 'Science', 'English', 'History', 'Computer'] df = pd.DataFrame(data, index=students, columns=subjects)
df.plot(kind='bar', figsize=(12, 6), colormap='viridis') plt.title('Marks of 10 Students in 5 Different Subjects') plt.xlabel('Students') plt.ylabel('Marks') plt.legend(title='Subjects', bbox_to_anchor=(1.05, 1), loc='upper left') plt.xticks(rotation=45) plt.tight_layout() plt.show()
Teacher’s Signature:-……………………………..
Output Teacher’s Signature:-……………………………..
np.random.seed(0) ages = np.random.randint(22, 61, 100) plt.figure(figsize=(8, 5)) plt.hist(ages, bins=10, color='skyblue', edgecolor='black') plt.title('Age Distribution of 100 Employees') plt.xlabel('Age') plt.ylabel('Number of Employees') plt.show()
print("Interpretation:") print("The histogram shows the frequency of employees across different age groups.") print("It helps identify which age ranges have the highest or lowest number of employees in the company.")
Output Teacher’s Signature:-……………………………..
Output Teacher’s Signature:-……………………………
iris = sns.load_dataset('iris')
plt.figure(figsize=(8, 5)) sns.boxplot(x=iris['sepal_width'], color='lightgreen') plt.title('Box Plot of Sepal Width in Iris Dataset') plt.xlabel('Sepal Width (cm)') plt.show()
print("Outlier Identification:") print("The individual dots located outside the 'whiskers' on either side of the box plot represent the outliers for the Sepal Width feature.")
7.Using the Titanic dataset, create a Count Plot showing the number of male and female passengers. Input:- import seaborn as sns import matplotlib.pyplot as plt
titanic = sns.load_dataset('titanic')
plt.figure(figsize=(7, 5)) sns.countplot(data=titanic, x='sex', hue='sex', palette='Set2', legend=False) plt.title('Number of Male and Female Passengers on Titanic') plt.xlabel('Gender') plt.ylabel('Passenger Count') plt.show()
Output Teacher’s Signature:-……………………………..
Output Teacher’s Signature:-……………………………..
california = fetch_california_housing(as_frame=True) df = california.frame
plt.figure(figsize=(10, 6)) plt.scatter(df['MedInc'], df['MedHouseVal'], alpha=0.4, color='teal', s=15) plt.title('Relationship between Median Income and Median House Value') plt.xlabel('Median Income (in Tens of Thousands of USD)') plt.ylabel('Median House Value (in Hundreds of Thousands of USD)') plt.grid(True, linestyle='--', alpha=0.5) plt.show()
iris = sns.load_dataset('iris')
sns.pairplot(iris, hue='species', palette='husl', markers=["o", "s", "D"]) plt.suptitle('Pair Plot of Iris Dataset by Species', y=1.02) plt.show()
print("Class Separation Identification:") print("- The 'setosa' species (usually the blue cluster) is highly distinct and easily separable from the other two species across almost all feature combinations.") print("- 'versicolor' and 'virginica' show some overlap, particularly in sepal length and sepal width, making them harder to separate completely.") print("- However, using Petal Length and Petal Width, 'versicolor' and 'virginica' can be separated much more clearly.")
Output Teacher’s Signature:-……………………………..