0% found this document useful (0 votes)
27 views5 pages

Lab 13

lab

Uploaded by

20-cs-112
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views5 pages

Lab 13

lab

Uploaded by

20-cs-112
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

DEPARTMENT OF COMPUTER SCIENCE

HITEC UNIVERSITY, TAXILA


Semester
“7 ”
TH

Section “C”
Lab report
#13

HUMAN COMPUTER INTERACTION

Submitted To:
Sir Abdullah shehroz

Submitted By:
ALIZA WAJID
20-CS-112
Code 1:
import numpy as np
import pandas as pd

# Create a NumPy array with student data


student_data = np.array([
['Alice', 20, 85],
['Bob', 22, 92],
['Charlie', 21, 78],
['David', 23, 95],
['Emma', 20, 88]
])

# Define column names


columns = ['Name', 'Age', 'Test_Score']

# Create a Pandas DataFrame


df = pd.DataFrame(student_data, columns=columns)

# Display the original DataFrame


print("Original DataFrame:")
print(df)
print()

# Convert 'Test_Score' column to numeric values


df['Test_Score'] = pd.to_numeric(df['Test_Score'])

# Filter students with a test score greater than 90


high_score_students = df[df['Test_Score'] > 90]

# Display the filtered DataFrame


print("Students with Test Score > 90:")
print(high_score_students)
print()

Code 2:
import numpy as np
import pandas as pd

# Create a NumPy array with student test scores


test_scores = np.array([85, 92, 78, 95, 88, 92, 85, 78, 95, 88, 78, 92, 95, 85])

# Create a Pandas DataFrame


df = pd.DataFrame({'Test_Score': test_scores})

# Calculate the frequency distribution using value_counts


frequency_distribution = df['Test_Score'].value_counts()

# Convert the frequency distribution to a DataFrame


frequency_df = pd.DataFrame({'Test_Score': frequency_distribution.index, 'Frequency':
frequency_distribution.values})

# Sort the DataFrame by test scores in ascending order


sorted_frequency_df = frequency_df.sort_values(by='Test_Score')

# Display the original DataFrame


print("Original DataFrame:")
print(df)
print()

# Display the frequency distribution


print("Frequency Distribution:")
print(frequency_df)
print()

# Display the sorted frequency distribution


print("Sorted Frequency Distribution:")
print(sorted_frequency_df)

Code 3:
import numpy as np
import matplotlib.pyplot as plt

# Generate data
x_line = np.linspace(0, 10, 100)
y_line = np.sin(x_line)

x_scatter = np.random.rand(50)
y_scatter = np.random.rand(50)

categories = ['Category A', 'Category B', 'Category C']


values = [20, 35, 45]
data_for_bar_chart = np.arange(len(categories))

data_for_histogram = np.random.randn(1000)

# Create a line chart


plt.figure(figsize=(12, 4))
plt.subplot(141)
plt.plot(x_line, y_line, label='sin(x)')
plt.title('Line Chart')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.legend()

# Create a scatter plot


plt.subplot(142)
plt.scatter(x_scatter, y_scatter, color='r', marker='o', label='Scatter Plot')
plt.title('Scatter Plot')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.legend()

# Create a bar chart


plt.subplot(143)
plt.bar(data_for_bar_chart, values, tick_label=categories, color=['red', 'green', 'blue'])
plt.title('Bar Chart')
plt.xlabel('Categories')
plt.ylabel('Values')

# Create a histogram
plt.subplot(144)
plt.hist(data_for_histogram, bins=30, color='purple', alpha=0.7)
plt.title('Histogram')
plt.xlabel('Values')
plt.ylabel('Frequency')

# Adjust layout to prevent overlap


plt.tight_layout()

# Show the plots


plt.show()

You might also like