words per minute
3
AtharvJaiswal
00:00
Speed
import numpy as np
import matplotlib.pyplot as plt
# Generate random data
np.random.seed(0)
hours_played = np.random.randint(1, 10, size=20) # Random hours played (1 to 10)
scores = 50 + 5 * hours_played + np.random.normal(0, 2, 20) # Random scores with noise
# Data Analysis
mean_hours = np.mean(hours_played)
mean_scores = np.mean(scores)
correlation = np.corrcoef(hours_played, scores)[0, 1]
# Print results
print(f"Mean hours played: {mean_hours:.2f}")
print(f"Mean scores: {mean_scores:.2f}")
print(f"Correlation between hours played and scores: {correlation:.2f}")
# Create a scatter plot
plt.figure(figsize=(8, 6))
plt.scatter(hours_played, scores, c='blue', label='Data Points')
plt.xlabel('Hours Played')
plt.ylabel('Scores')
plt.title('Hours Played vs. Scores')
plt.legend()
plt.show()