Cau1

# Đặt seed để kết quả cố định (có thể tái lập lại)
set.seed(3)

data <- rnorm(n = 500, mean = 50, sd = 15)
head(data)
## [1] 35.57100 45.61211 53.88182 32.71802 52.93674 50.45186
ket_qua_kiem_dinh <- shapiro.test(data)

print(ket_qua_kiem_dinh)
## 
##  Shapiro-Wilk normality test
## 
## data:  data
## W = 0.99674, p-value = 0.4113

Cau 2

data(iris)
write.csv(iris, "iris.csv", row.names = FALSE)
import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_csv("iris.csv")
print(df.head())
##    Sepal.Length  Sepal.Width  Petal.Length  Petal.Width Species
## 0           5.1          3.5           1.4          0.2  setosa
## 1           4.9          3.0           1.4          0.2  setosa
## 2           4.7          3.2           1.3          0.2  setosa
## 3           4.6          3.1           1.5          0.2  setosa
## 4           5.0          3.6           1.4          0.2  setosa
variances = df.var(numeric_only=True)
print(variances)
## Sepal.Length    0.685694
## Sepal.Width     0.189979
## Petal.Length    3.116278
## Petal.Width     0.581006
## dtype: float64
#Vẽ biểu đồ scatter
plt.figure(figsize=(8, 6))

plt.scatter(x=df['Sepal.Length'], y=df['Sepal.Width'], c='red', alpha=0.8, label='Iris Data')

plt.title('Biểu đồ Scatter: Chiều dài vs Chiều rộng Đài hoa')
plt.xlabel('Sepal.Length')
plt.ylabel('Sepal.Width')
plt.legend()
plt.grid(True)
plt.show()